Skip to content

Fix: tests/test_furl.py::test_hosts (and the analogous case in test_netloc)... - #198

Open
M001N wants to merge 1 commit into
gruns:masterfrom
M001N:oss-engine/4fc367c5-80231dbc
Open

Fix: tests/test_furl.py::test_hosts (and the analogous case in test_netloc)...#198
M001N wants to merge 1 commit into
gruns:masterfrom
M001N:oss-engine/4fc367c5-80231dbc

Conversation

@M001N

@M001N M001N commented Aug 10, 2026

Copy link
Copy Markdown

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

… 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.
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

Successfully merging this pull request may close these issues.

1 participant