From 6c6c29a9c79b6109d49d8957237ab1121ab1466f Mon Sep 17 00:00:00 2001 From: Alexander Shadchin Date: Wed, 21 Jun 2023 14:46:45 +0300 Subject: [PATCH 1/3] Fix tests with Python 3.11.4+ --- tests/test_url.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_url.py b/tests/test_url.py index 5f8faf29..bd0e1560 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -1,3 +1,4 @@ +import sys import os import unittest from inspect import isclass @@ -386,7 +387,6 @@ def test_safe_url_string_encoding( "http://192.168.0.256", # Invalid IP address "http://192.168.0.0.0", # Invalid IP address / domain name "http://[2a01:5cc0:1:2::4]", # https://github.com/scrapy/w3lib/issues/193 - "http://[2a01:5cc0:1:2:3:4]", # Invalid IPv6 "https://example.com:", # Removes the : # Does not convert \ to / "https://example.com\\a", @@ -418,6 +418,10 @@ def test_safe_url_string_encoding( # (%) are not escaped. f"a://example.com#{FRAGMENT_TO_ENCODE}", } +if sys.version_info < (3, 11, 4): + KNOWN_SAFE_URL_STRING_URL_ISSUES.add("http://[2a01:5cc0:1:2:3:4]") # Invalid IPv6 +else: + KNOWN_SAFE_URL_STRING_URL_ISSUES.add(f"https://{USERNAME_TO_ENCODE}:{PASSWORD_TO_ENCODE}@example.com") @pytest.mark.parametrize( From 8b3ec31305216c53aec20ee7c4d816ca59876c1a Mon Sep 17 00:00:00 2001 From: Alexander Shadchin Date: Tue, 4 Jul 2023 00:58:00 +0300 Subject: [PATCH 2/3] Aplay black --- tests/test_url.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_url.py b/tests/test_url.py index bd0e1560..4dd1b258 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -421,7 +421,9 @@ def test_safe_url_string_encoding( if sys.version_info < (3, 11, 4): KNOWN_SAFE_URL_STRING_URL_ISSUES.add("http://[2a01:5cc0:1:2:3:4]") # Invalid IPv6 else: - KNOWN_SAFE_URL_STRING_URL_ISSUES.add(f"https://{USERNAME_TO_ENCODE}:{PASSWORD_TO_ENCODE}@example.com") + KNOWN_SAFE_URL_STRING_URL_ISSUES.add( + f"https://{USERNAME_TO_ENCODE}:{PASSWORD_TO_ENCODE}@example.com" + ) @pytest.mark.parametrize( From 6a5235aeb4fe6a9cff4565898222ee324660132e Mon Sep 17 00:00:00 2001 From: Alexander Shadchin Date: Fri, 7 Jul 2023 10:05:23 +0300 Subject: [PATCH 3/3] Rework fix test for USERNAME_TO_ENCODE --- tests/test_url.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test_url.py b/tests/test_url.py index 4dd1b258..19fa4605 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -103,7 +103,7 @@ if ( chr(value) not in _C0_CONTROL_OR_SPACE and chr(value) not in USERINFO_SAFE - and chr(value) not in ":/?#\\" + and chr(value) not in ":/?#\\[]" ) ) USERNAME_ENCODED = "".join(f"%{ord(char):02X}" for char in USERNAME_TO_ENCODE) @@ -420,10 +420,6 @@ def test_safe_url_string_encoding( } if sys.version_info < (3, 11, 4): KNOWN_SAFE_URL_STRING_URL_ISSUES.add("http://[2a01:5cc0:1:2:3:4]") # Invalid IPv6 -else: - KNOWN_SAFE_URL_STRING_URL_ISSUES.add( - f"https://{USERNAME_TO_ENCODE}:{PASSWORD_TO_ENCODE}@example.com" - ) @pytest.mark.parametrize(