Skip to content

Commit 5357628

Browse files
authored
Fix tests with Python 3.11.4+ (#213)
1 parent 0e430ca commit 5357628

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_url.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import os
23
import unittest
34
from inspect import isclass
@@ -102,7 +103,7 @@
102103
if (
103104
chr(value) not in _C0_CONTROL_OR_SPACE
104105
and chr(value) not in USERINFO_SAFE
105-
and chr(value) not in ":/?#\\"
106+
and chr(value) not in ":/?#\\[]"
106107
)
107108
)
108109
USERNAME_ENCODED = "".join(f"%{ord(char):02X}" for char in USERNAME_TO_ENCODE)
@@ -386,7 +387,6 @@ def test_safe_url_string_encoding(
386387
"http://192.168.0.256", # Invalid IP address
387388
"http://192.168.0.0.0", # Invalid IP address / domain name
388389
"http://[2a01:5cc0:1:2::4]", # https://github.com/scrapy/w3lib/issues/193
389-
"http://[2a01:5cc0:1:2:3:4]", # Invalid IPv6
390390
"https://example.com:", # Removes the :
391391
# Does not convert \ to /
392392
"https://example.com\\a",
@@ -418,6 +418,8 @@ def test_safe_url_string_encoding(
418418
# (%) are not escaped.
419419
f"a://example.com#{FRAGMENT_TO_ENCODE}",
420420
}
421+
if sys.version_info < (3, 11, 4):
422+
KNOWN_SAFE_URL_STRING_URL_ISSUES.add("http://[2a01:5cc0:1:2:3:4]") # Invalid IPv6
421423

422424

423425
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)