-
-
Notifications
You must be signed in to change notification settings - Fork 590
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 failures with Python 3.12 #1428
Labels
Bug
Bug report in proxy server
Comments
FWICS #1347 was supposed to address a part of the problem. |
The other problem is technically solved by doing: diff --git a/tests/http/web/test_web_server.py b/tests/http/web/test_web_server.py
index 71baac4..e7b2e7a 100644
--- a/tests/http/web/test_web_server.py
+++ b/tests/http/web/test_web_server.py
@@ -180,7 +180,7 @@ class TestWebServerPluginWithPacFilePlugin(Assertions):
self.protocol_handler.request.state,
httpParserStates.COMPLETE,
)
- self._conn.send.called_once_with(
+ self._conn.send.assert_called_once_with(
build_http_response(
200,
reason=b'OK', but that uncovers that the test didn't work: ============================================================== FAILURES ===============================================================
_________________ TestWebServerPluginWithPacFilePlugin.test_pac_file_served_from_disk[/tmp/proxy.py/helper/proxy.pac] _________________
__wrapped_mock_method__ = <function NonCallableMock.assert_called_once_with at 0x7f53b8319360>
args = (<MagicMock name='socket().send' id='139997494054288'>, b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-auto... 80\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host)\n{\n\treturn "PROXY localhost:8899; DIRECT";\n}\n')
kwargs = {}, __tracebackhide__ = True, msg = "Expected 'send' to be called once. Called 0 times."
__mock_self = <MagicMock name='socket().send' id='139997494054288'>
def assert_wrapper(
__wrapped_mock_method__: Callable[..., Any], *args: Any, **kwargs: Any
) -> None:
__tracebackhide__ = True
try:
> __wrapped_mock_method__(*args, **kwargs)
__mock_self = <MagicMock name='socket().send' id='139997494054288'>
__tracebackhide__ = True
__wrapped_mock_method__ = <function NonCallableMock.assert_called_once_with at 0x7f53b8319360>
args = (<MagicMock name='socket().send' id='139997494054288'>, b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-auto... 80\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host)\n{\n\treturn "PROXY localhost:8899; DIRECT";\n}\n')
kwargs = {}
msg = "Expected 'send' to be called once. Called 0 times."
.tox/py310/lib/python3.10/site-packages/pytest_mock/plugin.py:414:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock name='socket().send' id='139997494054288'>
args = (b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-autoconfig\r\nContent-Length: 80\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host)\n{\n\treturn "PROXY localhost:8899; DIRECT";\n}\n',)
kwargs = {}, msg = "Expected 'send' to be called once. Called 0 times."
def assert_called_once_with(self, /, *args, **kwargs):
"""assert that the mock was called exactly once and that that call was
with the specified arguments."""
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times.%s"
% (self._mock_name or 'mock',
self.call_count,
self._calls_repr()))
> raise AssertionError(msg)
E AssertionError: Expected 'send' to be called once. Called 0 times.
args = (b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-autoconfig\r\nContent-Length: 80\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host)\n{\n\treturn "PROXY localhost:8899; DIRECT";\n}\n',)
kwargs = {}
msg = "Expected 'send' to be called once. Called 0 times."
self = <MagicMock name='socket().send' id='139997494054288'>
/usr/lib/python3.10/unittest/mock.py:940: AssertionError
During handling of the above exception, another exception occurred:
self = <tests.http.web.test_web_server.TestWebServerPluginWithPacFilePlugin object at 0x7f53b7705600>
@pytest.mark.asyncio # type: ignore[misc]
async def test_pac_file_served_from_disk(self) -> None:
await self.protocol_handler._run_once()
self.assertEqual(
self.protocol_handler.request.state,
httpParserStates.COMPLETE,
)
> self._conn.send.assert_called_once_with(
build_http_response(
200,
reason=b'OK',
headers={
b'Content-Type': b'application/x-ns-proxy-autoconfig',
},
body=self.expected_response,
conn_close=True,
),
)
E AssertionError: Expected 'send' to be called once. Called 0 times.
self = <tests.http.web.test_web_server.TestWebServerPluginWithPacFilePlugin object at 0x7f53b7705600>
tests/http/web/test_web_server.py:183: AssertionError
_ TestWebServerPluginWithPacFilePlugin.test_pac_file_served_from_disk[function FindProxyForURL(url, host) { return "PROXY localhost:8899; DIRECT"; }] _
__wrapped_mock_method__ = <function NonCallableMock.assert_called_once_with at 0x7f53b8319360>
args = (<MagicMock name='socket().send' id='139997494341984'>, b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-auto...Length: 78\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host) { return "PROXY localhost:8899; DIRECT"; }')
kwargs = {}, __tracebackhide__ = True, msg = "Expected 'send' to be called once. Called 0 times."
__mock_self = <MagicMock name='socket().send' id='139997494341984'>
def assert_wrapper(
__wrapped_mock_method__: Callable[..., Any], *args: Any, **kwargs: Any
) -> None:
__tracebackhide__ = True
try:
> __wrapped_mock_method__(*args, **kwargs)
__mock_self = <MagicMock name='socket().send' id='139997494341984'>
__tracebackhide__ = True
__wrapped_mock_method__ = <function NonCallableMock.assert_called_once_with at 0x7f53b8319360>
args = (<MagicMock name='socket().send' id='139997494341984'>, b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-auto...Length: 78\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host) { return "PROXY localhost:8899; DIRECT"; }')
kwargs = {}
msg = "Expected 'send' to be called once. Called 0 times."
.tox/py310/lib/python3.10/site-packages/pytest_mock/plugin.py:414:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock name='socket().send' id='139997494341984'>
args = (b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-autoconfig\r\nContent-Length: 78\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host) { return "PROXY localhost:8899; DIRECT"; }',)
kwargs = {}, msg = "Expected 'send' to be called once. Called 0 times."
def assert_called_once_with(self, /, *args, **kwargs):
"""assert that the mock was called exactly once and that that call was
with the specified arguments."""
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times.%s"
% (self._mock_name or 'mock',
self.call_count,
self._calls_repr()))
> raise AssertionError(msg)
E AssertionError: Expected 'send' to be called once. Called 0 times.
args = (b'HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-autoconfig\r\nContent-Length: 78\r\nConnection: close\r\n\r\nfunction FindProxyForURL(url, host) { return "PROXY localhost:8899; DIRECT"; }',)
kwargs = {}
msg = "Expected 'send' to be called once. Called 0 times."
self = <MagicMock name='socket().send' id='139997494341984'>
/usr/lib/python3.10/unittest/mock.py:940: AssertionError
During handling of the above exception, another exception occurred:
self = <tests.http.web.test_web_server.TestWebServerPluginWithPacFilePlugin object at 0x7f53b7705ab0>
@pytest.mark.asyncio # type: ignore[misc]
async def test_pac_file_served_from_disk(self) -> None:
await self.protocol_handler._run_once()
self.assertEqual(
self.protocol_handler.request.state,
httpParserStates.COMPLETE,
)
> self._conn.send.assert_called_once_with(
build_http_response(
200,
reason=b'OK',
headers={
b'Content-Type': b'application/x-ns-proxy-autoconfig',
},
body=self.expected_response,
conn_close=True,
),
)
E AssertionError: Expected 'send' to be called once. Called 0 times.
self = <tests.http.web.test_web_server.TestWebServerPluginWithPacFilePlugin object at 0x7f53b7705ab0>
tests/http/web/test_web_server.py:183: AssertionError
----------------------------- generated xml file: /tmp/proxy.py/.tox/tmp/test-results/pytest/results.xml ------------------------------
======================================================== slowest 10 durations =========================================================
1.40s call tests/test_main.py::TestProxyContextManager::test_proxy_context_manager
1.13s call tests/core/test_event_dispatcher.py::TestEventDispatcher::test_empties_queue
1.12s call tests/core/test_event_subscriber.py::TestEventSubscriber::test_event_subscriber
1.03s teardown tests/testing/test_embed.py::TestProxyPyEmbedded::test_with_proxy
0.87s teardown tests/http/proxy/test_http2.py::TestHttp2WithProxy::test_http2_via_proxy
0.27s call tests/http/proxy/test_http2.py::TestHttp2WithProxy::test_http2_via_proxy
0.16s call tests/common/test_pki.py::TestPki::test_gen_private_key
0.14s call tests/core/test_event_dispatcher.py::TestEventDispatcher::test_subscribe
0.13s call tests/core/test_event_queue.py::TestCoreEvent::test_publish
0.13s call tests/core/test_event_dispatcher.py::TestEventDispatcher::test_unsubscribe
======================================================= short test summary info =======================================================
FAILED tests/http/web/test_web_server.py::TestWebServerPluginWithPacFilePlugin::test_pac_file_served_from_disk[/tmp/proxy.py/helper/proxy.pac]
FAILED tests/http/web/test_web_server.py::TestWebServerPluginWithPacFilePlugin::test_pac_file_served_from_disk[function FindProxyForURL(url, host) { return "PROXY localhost:8899; DIRECT"; }]
=================================================== 2 failed, 220 passed in 11.58s ==================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When running the test suite with Python 3.12.4, I'm getting a bunch of test failures (plus these from #1426):
To Reproduce
tox -e py312
Expected behavior
Tests passing.
Version information
The text was updated successfully, but these errors were encountered: