Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions test/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -112,24 +112,20 @@ 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 [
b'',
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'
]
Loading