test_httpcore_lazy_loading cannot run on its own #3791
Unanswered
meagoodboy
asked this question in
Potential Issue
Replies: 1 comment
|
Hi! I would love to take this up and fix it. Using Could you please assign this to me or confirm so I can submit a clean PR for this? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
tests/test_api.py::test_httpcore_lazy_loadingfails when it runs before any test that has performed a request, including when it is run by itself:The cleanup assumes that whenever
httpxis insys.modules,httpcoreis too. Buthttpcoreis only imported once a request is made (which is the very behaviour this test checks), so if no earlier test has made a request the deletion raisesKeyError. The test currently passes in the full suite only because sibling tests in the same file run first and make requests. Running the file's tests in reverse order fails the same way (1 failed, 11 passed).Suggested fix, which I am happy to send as a PR:
With that change the test passes standalone, in natural order, and in reverse order. Seen on macOS arm64, Python 3.13, pytest 9.1.1, at master b5addb6.
All reactions