Repository navigation
test: use local httpserver for urllib tests - #562
Merged
Merged
Conversation
The three urllib tests in test_socket.py fetched https://http.codes/200, which now returns 503 and fails every macOS and Ubuntu job. Point them at the session httpserver fixture instead. --disable-socket and the disable_socket marker block socket construction for any host, so loopback still proves allow and block behavior. Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Contributor
Merging this PR will degrade performance by 1.93%1 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing |
The generated urllib tests were all named test_disable_socket_urllib, including the two that expect the request to succeed. Name them test_urllib, and drop the import pytest_socket lines that nothing used. Signed-off-by: Mike Fiedler <miketheman@gmail.com>
miketheman
force-pushed
the
test-local-httpserver
branch
from
October 21, 2026 12:52
0e238ae to
287eb0e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The three urllib tests in
tests/test_socket.pyfetchedhttps://http.codes/200, which now returns503 Maintenance. That fails every macOS and Ubuntu job, including #561. This is the second public endpoint these tests have outlived: httpbin.org was replaced in #231 and httpstat.us in #426.The tests now use the existing session
httpserverfixture fromconftest.py.--disable-socketand thedisable_socketmarker block socket construction regardless of host, so a loopback URL still tells allowed from blocked. I checked by breaking each test on purpose:@pytest.mark.disable_socketlets the request through, andtest_disabled_urllib_failsfails@pytest.mark.enable_socketblocks the request, andtest_enabled_urllib_succeedsfails--disable-socketblocks the request, andtest_urllib_succeeds_by_defaultfailsThese tests no longer go through DNS or TLS, but none of them asserted anything about either.
test_combinations.py(google.com, amazon.com, microsoft.com) andtest_precedence.py:137(DNS lookup of google.com) still need network access. They're left for a follow-up.