Skip to content

Commit 869bf81

Browse files
ajohnston9Andrew Johnston
and
Andrew Johnston
authored
Fix tests so they're compatible with both ujson and pure json library (#26)
Co-authored-by: Andrew Johnston <[email protected]>
1 parent 1a5ef44 commit 869bf81

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Diff for: test/test_streams.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,20 @@ def test_writer(wfile, writer):
8282
'method': 'method',
8383
'params': {}
8484
})
85-
86-
assert wfile.getvalue() == (
87-
b'Content-Length: 44\r\n'
88-
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
89-
b'\r\n'
90-
b'{"id":"hello","method":"method","params":{}}'
91-
)
85+
if 'ujson' in sys.modules:
86+
assert wfile.getvalue() == (
87+
b'Content-Length: 44\r\n'
88+
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
89+
b'\r\n'
90+
b'{"id":"hello","method":"method","params":{}}'
91+
)
92+
else:
93+
assert wfile.getvalue() == (
94+
b'Content-Length: 49\r\n'
95+
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
96+
b'\r\n'
97+
b'{"id": "hello", "method": "method", "params": {}}'
98+
)
9299

93100

94101
class JsonDatetime(datetime.datetime):

0 commit comments

Comments
 (0)