Skip to content

Commit 7718a39

Browse files
committed
Make the writer datetime test independent of local timezone
1 parent a96d764 commit 7718a39

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎test/test_streams.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_writer(wfile, writer):
9999

100100

101101
class JsonDatetime(datetime.datetime):
102-
"""Monkey path json datetime."""
102+
"""Datetime with a custom JSON representation for ujson."""
103103
def __json__(self):
104104
if sys.version_info.major == 3:
105105
dif = int(self.timestamp())
@@ -112,24 +112,20 @@ def test_writer_bad_message(wfile, writer):
112112
# A datetime isn't serializable(or poorly serializable),
113113
# ensure the write method doesn't throw, but the result could be empty
114114
# or the correct datetime
115-
datetime.datetime = JsonDatetime
116-
writer.write(datetime.datetime(
115+
writer.write(JsonDatetime(
117116
year=2019,
118117
month=1,
119118
day=1,
120119
hour=1,
121120
minute=1,
122121
second=1,
122+
tzinfo=datetime.timezone.utc,
123123
))
124124

125125
assert wfile.getvalue() in [
126126
b'',
127127
b'Content-Length: 10\r\n'
128128
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
129129
b'\r\n'
130-
b'1546304461',
131-
b'Content-Length: 10\r\n'
132-
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
133-
b'\r\n'
134-
b'1546322461'
130+
b'1546304461'
135131
]

0 commit comments

Comments
 (0)