Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test test_writer_bad_message fails with ujson #6

Open
jelly opened this issue Aug 27, 2021 · 2 comments
Open

Test test_writer_bad_message fails with ujson #6

jelly opened this issue Aug 27, 2021 · 2 comments

Comments

@jelly
Copy link

jelly commented Aug 27, 2021

====================================== FAILURES ======================================
______________________________ test_writer_bad_message _______________________________

wfile = <_io.BytesIO object at 0x7f76043e6d60>
writer = <pylsp_jsonrpc.streams.JsonRpcStreamWriter object at 0x7f760392a8e0>

    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(
            year=2019,
            month=1,
            day=1,
            hour=1,
            minute=1,
            second=1,
        ))

>       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'
        ]
E       AssertionError: assert b'Content-Length: 10\r\nContent-Type: application/vscode-jsonrpc; charset=utf8\r\n\r\n1546300861' in [b'', b'Content-Length: 10\r\nContent-Type: application/vscode-jsonrpc; charset=utf8\r\n\r\n1546304461', b'Content-Length: 10\r\nContent-Type: application/vscode-jsonrpc; charset=utf8\r\n\r\n1546322461']
E        +  where b'Content-Length: 10\r\nContent-Type: application/vscode-jsonrpc; charset=utf8\r\n\r\n1546300861' = <built-in method getvalue of _io.BytesIO object at 0x7f76043e6d60>()
E        +    where <built-in method getvalue of _io.BytesIO object at 0x7f76043e6d60> = <_io.BytesIO object at 0x7f76043e6d60>.getvalue

test/test_streams.py:118: AssertionError
============================== short test summary info ===============================
FAILED test/test_streams.py::test_writer_bad_message - AssertionError: assert b'Con...
============================ 1 failed, 26 passed in 0.10s ============================
jelly added a commit to jelly/python-lsp-jsonrpc that referenced this issue Aug 27, 2021
The correct timestamp value of
`datetime.datetime(2019, 1, 1, 1, 1,1).timestamp()` is 1546300861.

Closes: python-lsp#6
itsbenweeks pushed a commit to itsbenweeks/python-lsp-jsonrpc that referenced this issue Feb 1, 2022
@papoteur-mga
Copy link

I still get the same error with the 1.1.1 release.

@lcheylus
Copy link

lcheylus commented Oct 3, 2023

Same error with release 1.1.2 on OpenBSD with Python 3.10 and ujson-5.8.0

===>  Regression tests for py3-python-lsp-jsonrpc-1.1.2
============================= test session starts ==============================
platform openbsd7 -- Python 3.10.13, pytest-7.1.3, pluggy-1.2.0
rootdir: /usr/obj/ports/py-python-lsp-jsonrpc-1.1.2-python3/python-lsp-jsonrpc-1.1.2, configfile: pyproject.toml, testpaths: test
plugins: mock-3.10.0, cov-4.0.0
collected 27 items

test/test_endpoint.py ......................                             [ 81%]
test/test_streams.py ....F                                               [100%]

=================================== FAILURES ===================================
___________________________ test_writer_bad_message ____________________________

wfile = <_io.BytesIO object at 0xe55f47a36a0>
writer = <pylsp_jsonrpc.streams.JsonRpcStreamWriter object at 0xe55f475a350>

    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(
            year=2019,
            month=1,
            day=1,
            hour=1,
            minute=1,
            second=1,
        ))

>       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'
        ]
E       AssertionError: assert b'Content-Length: 10\r\nContent-Type: application/vscode-jsonrpc; charset=utf8\r\n\r\n1546300861' in [b'', b'Content-Length: 10\r\nContent-Type: application/vscode-jsonrpc; charset=utf8\r\n\r\n1546304461', b'Content-Length: 10\r\nContent-Type:
 application/vscode-jsonrpc; charset=utf8\r\n\r\n1546322461']
E        +  where b'Content-Length: 10\r\nContent-Type: application/vscode-jsonrpc; charset=utf8\r\n\r\n1546300861' = <built-in method getvalue of _io.BytesIO object at 0xe55f47a36a0>()
E        +    where <built-in method getvalue of _io.BytesIO object at 0xe55f47a36a0> = <_io.BytesIO object at 0xe55f47a36a0>.getvalue

test/test_streams.py:125: AssertionError
- generated xml file: /usr/obj/ports/py-python-lsp-jsonrpc-1.1.2-python3/python-lsp-jsonrpc-1.1.2/pytest.xml -
- (...)
- =========================== short test summary info ============================
FAILED test/test_streams.py::test_writer_bad_message - AssertionError: assert...
========================= 1 failed, 26 passed in 0.52s =========================
- ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants