Fix: tests/test_furl.py::test_hosts (and the analogous case in test_netloc)... - #198
Open
M001N wants to merge 1 commit into
Open
Fix: tests/test_furl.py::test_hosts (and the analogous case in test_netloc)...#198M001N wants to merge 1 commit into
M001N wants to merge 1 commit into
Conversation
… validation urllib.parse added _check_bracketed_host validation in Python 3.9 that raises ValueError for invalid-but-well-formed IPv6 addresses like 0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999. The tests assumed the pre-3.9 behavior (no exception) unconditionally. Guard the assertions with sys.version_info since CI still tests Python 3.8.
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.
Summary
Guarded the assertions in both test_hosts and test_netloc with
sys.version_info < (3, 9): on <3.9 the original no-exception/side-effect assertions are kept, on >=3.9 the calls are wrapped in assertRaises(ValueError) and the 'no side effects' check in test_netloc is updated to reflect the values that remain after the raised assignment (host/port from the prior successful assignment).Problem
gruns/furl issue reference: #182
Root Cause
tests/test_furl.py::test_hosts (and the analogous case in test_netloc) called furl.furl()/set netloc with an invalid-but-well-formed IPv6 bracketed host with no assertRaises, based on a comment that urllib.parse.urlsplit() never raises on such addresses. Since Python 3.9, urllib.parse added _check_bracketed_host validation that does raise ValueError for this address. CI (.github/workflows/ci.yml) still tests Python 3.8, which lacks this validation, so an unconditional assertRaises would break 3.8.
Testing
PASS for test_hosts and test_netloc (both green on Python 3.14, which exercises the >=3.9 branch). Full suite run shows 1 pre-existing unrelated failure (test_odd_urls, a '//////path' vs '////path' urlsplit quirk) confirmed via git stash to exist before this change too, so it's out of scope.
Related Issue
#182