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 error in Python 3.12 -Debian #274

Open
NGC2023 opened this issue Aug 17, 2024 · 1 comment
Open

Test error in Python 3.12 -Debian #274

NGC2023 opened this issue Aug 17, 2024 · 1 comment

Comments

@NGC2023
Copy link

NGC2023 commented Aug 17, 2024

Hi, I am getting the following test error while building the package in Debian unstable.

_____________________ ERROR at setup of test_plain_fixture _____________________
file /tmp/pytest-of-yogu/pytest-0/test_respx_mock_fixture0/test_respx_mock_fixture.py, line 8
  def test_plain_fixture(respx_mock):
E       fixture 'respx_mock' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, autojump_clock, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, event_loop, http_client, http_server, http_server_client, http_server_port, io_loop, mock_clock, monkeypatch, no_cover, nursery, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, some_fixture, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory, twisted_greenlet, unused_tcp_port, unused_tcp_port_factory, unused_udp_port, unused_udp_port_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/pytest-of-yogu/pytest-0/test_respx_mock_fixture0/test_respx_mock_fixture.py:8

I have created a patch to address this error,

--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -3,6 +3,7 @@ def test_respx_mock_fixture(testdir):
         """
         import httpx
         import pytest
+        from respx.plugin import respx_mock
 
         @pytest.fixture
         def some_fixture():

There is a deprecated warning too,

.pybuild/cpython3_3.12_respx/build/tests/test_mock.py::test_proxies
  /usr/lib/python3/dist-packages/httpx/_client.py:671: DeprecationWarning: The 'proxies' argument is now deprecated. Use 'proxy' or 'mounts' instead.
    warnings.warn(message, DeprecationWarning)

Fix for the warning below,

--- a/tests/test_mock.py
+++ b/tests/test_mock.py
@@ -476,14 +476,14 @@ def test_add_remove_targets():
 async def test_proxies():
     with respx.mock:
         respx.get("https://foo.bar/") % dict(json={"foo": "bar"})
-        with httpx.Client(proxies={"https://": "https://1.1.1.1:1"}) as client:
+        with httpx.Client(proxy={"https://": "https://1.1.1.1:1"}) as client:
             response = client.get("https://foo.bar/")
         assert response.json() == {"foo": "bar"}
 
     async with respx.mock:
         respx.get("https://foo.bar/") % dict(json={"foo": "bar"})
         async with httpx.AsyncClient(
-            proxies={"https://": "https://1.1.1.1:1"}
+            proxy={"https://": "https://1.1.1.1:1"}
         ) as client:
             response = await client.get("https://foo.bar/")
         assert response.json() == {"foo": "bar"}
@lundberg
Copy link
Owner

lundberg commented Sep 2, 2024

Thanks, we should address the warnings 👍

About the test_respx_mock_fixture test, it's testing that the pytest respx plugin works by supplying/forcing -p respx when executing, to simulate a proper user environment, without your suggested import.

This probably breaks for you due to where executed, e.g. python path, virtual environment etc

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

No branches or pull requests

2 participants