From 8bbca32edc344c7ee2f5ea5db5448a4c4ff79684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 22 Mar 2019 15:54:58 +0100 Subject: Fix timezone in tests --- tests/helper.py | 6 +++++- tests/test_portfolio.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/helper.py b/tests/helper.py index a2f8a22..930d04a 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -5,9 +5,10 @@ from unittest import mock import requests_mock from io import StringIO import portfolio, market, main, store, dbs +import datetime __all__ = ["limits", "unittest", "WebMockTestCase", "mock", "D", - "StringIO"] + "StringIO", "tz"] limits = ["acceptance", "unit"] for test_type in limits: @@ -19,6 +20,9 @@ for test_type in limits: limits = [test_type] break +def tz(hours): + return datetime.timezone(datetime.timedelta(hours=hours)) + class WebMockTestCase(unittest.TestCase): import time diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index cad3095..f2f6394 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -1361,7 +1361,7 @@ class OrderTest(WebMockTestCase): with self.subTest(similar_open_order=True): order = portfolio.Order("buy", portfolio.Amount("ETH", "0.001"), D("0.1"), "BTC", "long", self.m, "trade") - order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55) + order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55, 0, tz(2)) self.m.ccxt.order_precision.return_value = 8 self.m.ccxt.fetch_orders.return_value = [ @@ -1471,7 +1471,7 @@ class OrderTest(WebMockTestCase): with self.subTest(similar_open_order=False, past_trades=True): order = portfolio.Order("buy", portfolio.Amount("ETH", "0.001"), D("0.1"), "BTC", "long", self.m, "trade") - order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55) + order.start_date = datetime.datetime(2018, 3, 25, 15, 15, 55, 0, tz(2)) self.m.ccxt.order_precision.return_value = 8 self.m.ccxt.fetch_orders.return_value = [] -- cgit v1.2.3