summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Fischer <yanlend@users.noreply.github.com>2020-07-30 16:48:51 +0200
committerGitHub <noreply@github.com>2020-07-30 23:48:51 +0900
commit8fb709f2e0438862020d8810fa70a81fb5dac7d4 (patch)
tree69c53d33afbc788149b99fe89a7784d7a85e79a6 /test
parent772c830841a276adb392dd449809764b2826b1f8 (diff)
downloadmsgpack-python-8fb709f2e0438862020d8810fa70a81fb5dac7d4.tar.gz
Fix datetime before epoch on windows in cython implementation (#436)
Cython implementation still used datetime.from_timestamp method, which does not work on windows. Update the cython implementation to use utc time and delta and add a regression test to highlight the issue.
Diffstat (limited to 'test')
-rw-r--r--test/test_timestamp.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/test_timestamp.py b/test/test_timestamp.py
index 823fe04..edc488a 100644
--- a/test/test_timestamp.py
+++ b/test/test_timestamp.py
@@ -100,6 +100,14 @@ def test_unpack_datetime():
@pytest.mark.skipif(sys.version_info[0] == 2, reason="datetime support is PY3+ only")
+def test_pack_unpack_before_epoch():
+ t_in = datetime.datetime(1960, 1, 1, tzinfo=_utc)
+ packed = msgpack.packb(t_in, datetime=True)
+ unpacked = msgpack.unpackb(packed, timestamp=3)
+ assert unpacked == t_in
+
+
+@pytest.mark.skipif(sys.version_info[0] == 2, reason="datetime support is PY3+ only")
def test_pack_datetime():
t = Timestamp(42, 14000)
dt = t.to_datetime()