googlearchive / pywebsocket

WebSocket server and extension for Apache HTTP Server for testing
BSD 3-Clause "New" or "Revised" License
309 stars 148 forks source link

Two test errors on Python 2 #154

Closed jayvdb closed 4 years ago

jayvdb commented 5 years ago

Two failures

_______________________ UnitTest.test_parse_invalid_uri ________________________
self = <test.test_http_header_util.UnitTest testMethod=test_parse_invalid_uri>
    def test_parse_invalid_uri(self):
        host, port, resource = http_header_util.parse_uri('ws:///')
        self.assertEqual(None, resource)

        host, port, resource = http_header_util.parse_uri('ws://localhost:')
>       self.assertEqual(None, resource)
E       AssertionError: None != '/'
test/test_http_header_util.py:80: AssertionError
_______________ MuxHandlerTest.test_add_channel_invalid_encoding _______________
self = <test.test_mux.MuxHandlerTest testMethod=test_add_channel_invalid_encoding>
    def test_add_channel_invalid_encoding(self):
        request = _create_mock_request()
        dispatcher = _MuxMockDispatcher()
        mux_handler = mux._MuxHandler(request, dispatcher)
        mux_handler.start()
        mux_handler.add_channel_slots(mux._INITIAL_NUMBER_OF_CHANNEL_SLOTS,
                                      mux._INITIAL_QUOTA_FOR_CLIENT)

        encoded_handshake = _create_request_header(path='/echo')
        add_channel_request = _create_add_channel_request_frame(
            channel_id=2, encoding=3,
            encoded_handshake=encoded_handshake)
        request.connection.put_bytes(add_channel_request)

        self.assertTrue(mux_handler.wait_until_done(timeout=2))

        drop_channel = next(
            b for b in request.connection.get_written_control_blocks()
            if b.opcode == mux._MUX_OPCODE_DROP_CHANNEL)
        self.assertEqual(mux._DROP_CODE_UNKNOWN_REQUEST_ENCODING,
                         drop_channel.drop_code)
        self.assertEqual(common.STATUS_INTERNAL_ENDPOINT_ERROR,
>                        request.connection.server_close_code)
E       AssertionError: 1011 != 1000
test/test_mux.py:965: AssertionError

See https://travis-ci.org/jayvdb/pywebsocket/jobs/512359637 for full log

jayvdb commented 5 years ago

Oddly, test_add_channel_invalid_encoding seems to have fixed itself.

test_parse_invalid_uri looks very easy to fix, but requires some knowledge of what should occur in this case.

ricea commented 5 years ago

test_parse_invalid_uri looks very easy to fix, but requires some knowledge of what should occur in this case.

I think treating the actual observed behaviour as de-facto correct is fine.

jayvdb commented 5 years ago

It seems a bit odd, assuming the test passed at some point.

In effect, somehow, the test result is inverted.

ricea commented 5 years ago

It seems a bit odd, assuming the test passed at some point.

I seem to remember that Python's urlparse module has been updated to be more standard-compliant. So that would explain the change in behaviour.

ricea commented 4 years ago

Fixed in pywebsocket3: https://github.com/GoogleChromeLabs/pywebsocket3

Version 1 of pywebsocket is no longer maintained so closing the issue here.