From 7718a3935322fab38f0bc5c2378440cd57d6f686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0brahim=20Sait=20Akar=C3=A7e=C5=9Fme?= <72226290+saitakarcesme@users.noreply.github.com> Date: Tue, 22 Sep 2026 03:17:48 +0200 Subject: [PATCH] Make the writer datetime test independent of local timezone --- test/test_streams.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/test_streams.py b/test/test_streams.py index 14fe1bb..cd663cc 100644 --- a/test/test_streams.py +++ b/test/test_streams.py @@ -99,7 +99,7 @@ def test_writer(wfile, writer): class JsonDatetime(datetime.datetime): - """Monkey path json datetime.""" + """Datetime with a custom JSON representation for ujson.""" def __json__(self): if sys.version_info.major == 3: dif = int(self.timestamp()) @@ -112,14 +112,14 @@ def test_writer_bad_message(wfile, writer): # A datetime isn't serializable(or poorly serializable), # ensure the write method doesn't throw, but the result could be empty # or the correct datetime - datetime.datetime = JsonDatetime - writer.write(datetime.datetime( + writer.write(JsonDatetime( year=2019, month=1, day=1, hour=1, minute=1, second=1, + tzinfo=datetime.timezone.utc, )) assert wfile.getvalue() in [ @@ -127,9 +127,5 @@ def test_writer_bad_message(wfile, writer): b'Content-Length: 10\r\n' b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n' b'\r\n' - b'1546304461', - b'Content-Length: 10\r\n' - b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n' - b'\r\n' - b'1546322461' + b'1546304461' ]