From 4a91ccdd7f4628b9bc403f843e463ca01e696af0 Mon Sep 17 00:00:00 2001 From: Andrew Johnston Date: Fri, 22 Sep 2023 15:53:12 -0400 Subject: [PATCH] Fixed tests so they're compatible with both ujson and pure json library --- test/test_streams.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/test_streams.py b/test/test_streams.py index 8ded7fe..14fe1bb 100644 --- a/test/test_streams.py +++ b/test/test_streams.py @@ -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):