Skip to content

Commit

Permalink
Fix tests so they're compatible with both ujson and pure json library (
Browse files Browse the repository at this point in the history
…#26)

Co-authored-by: Andrew Johnston <ahjohnston@google.com>
  • Loading branch information
ajohnston9 and Andrew Johnston authored Sep 23, 2023
1 parent 1a5ef44 commit 869bf81
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions test/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,20 @@ def test_writer(wfile, writer):
'method': 'method',
'params': {}
})

assert wfile.getvalue() == (
b'Content-Length: 44\r\n'
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
b'\r\n'
b'{"id":"hello","method":"method","params":{}}'
)
if 'ujson' in sys.modules:
assert wfile.getvalue() == (
b'Content-Length: 44\r\n'
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
b'\r\n'
b'{"id":"hello","method":"method","params":{}}'
)
else:
assert wfile.getvalue() == (
b'Content-Length: 49\r\n'
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
b'\r\n'
b'{"id": "hello", "method": "method", "params": {}}'
)


class JsonDatetime(datetime.datetime):
Expand Down

0 comments on commit 869bf81

Please sign in to comment.