From d39c13fd9c6993307dfe5c13635d6f1aa5a22ee7 Mon Sep 17 00:00:00 2001 From: Fabio Caccamo Date: Tue, 9 Jul 2019 18:36:19 +0200 Subject: [PATCH] Fixed get_datetime method from timestamp tests. --- tests/test_parse_dict.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_parse_dict.py b/tests/test_parse_dict.py index 81a7429..ed115d8 100644 --- a/tests/test_parse_dict.py +++ b/tests/test_parse_dict.py @@ -4,8 +4,9 @@ from benedict.dicts.parse import ParseDict from datetime import datetime from decimal import Decimal -from six import PY3 +from six import PY2, PY3 +import time import unittest @@ -91,21 +92,21 @@ class ParseDictTestCase(unittest.TestCase): def test_get_datetime_with_timestamp_int(self): now = datetime.now() - ts = datetime.timestamp(now) + ts = time.mktime(now.timetuple()) if PY2 else datetime.timestamp(now) d = { 'a': ts, } b = ParseDict(d) - self.assertEqual(b.get_datetime('a'), now) + self.assertEqual(b.get_datetime('a'), datetime.fromtimestamp(ts)) def test_get_datetime_with_timestamp_string(self): now = datetime.now() - ts = datetime.timestamp(now) + ts = time.mktime(now.timetuple()) if PY2 else datetime.timestamp(now) d = { 'a': str(ts), } b = ParseDict(d) - self.assertEqual(b.get_datetime('a'), now) + self.assertEqual(b.get_datetime('a'), datetime.fromtimestamp(ts)) def test_get_datetime_with_valid_format(self): d = {