summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2023-06-08 17:17:40 +0200
committerFlorian Bruhin <me@the-compiler.org>2023-06-08 17:17:40 +0200
commite1d0b3c543fc470a0459a18be3dee5a151ed79ed (patch)
tree4d89d21ad3827bce40f38574c2027e15588fd9f1
parent8b058389b7db591fb52b99fe9f7afbacfeabd901 (diff)
downloadqutebrowser-e1d0b3c543fc470a0459a18be3dee5a151ed79ed.tar.gz
qutebrowser-e1d0b3c543fc470a0459a18be3dee5a151ed79ed.zip
tests: Adjust urlmatch exception message patterns for Python 3.11.4
-rw-r--r--tests/unit/utils/test_urlmatch.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/tests/unit/utils/test_urlmatch.py b/tests/unit/utils/test_urlmatch.py
index c1b9e11be..820608138 100644
--- a/tests/unit/utils/test_urlmatch.py
+++ b/tests/unit/utils/test_urlmatch.py
@@ -40,6 +40,12 @@ from qutebrowser.utils import urlmatch
# FIXME:qt6 (lint): disable=line-too-long
+_INVALID_IP_MESSAGE = (
+ r'Invalid IPv6 address; source was ".*"; host = ""|'
+ r"'.*' does not appear to be an IPv4 or IPv6 address" # Python 3.11.4+
+)
+
+
@pytest.mark.parametrize('pattern, error', [
### Chromium: kMissingSchemeSeparator
## TEST(ExtensionURLPatternTest, ParseInvalid)
@@ -60,7 +66,11 @@ from qutebrowser.utils import urlmatch
pytest.param("http://:1234/", "Pattern without host", id='host-port'),
pytest.param("http://*./", "Pattern without host", id='host-pattern'),
## TEST(ExtensionURLPatternTest, IPv6Patterns)
- pytest.param("http://[]:8888/*", "Pattern without host", id='host-ipv6'),
+ pytest.param(
+ "http://[]:8888/*",
+ "Pattern without host|'' does not appear to be an IPv4 or IPv6 address",
+ id='host-ipv6',
+ ),
### Chromium: kEmptyPath
## TEST(ExtensionURLPatternTest, ParseInvalid)
@@ -87,19 +97,22 @@ from qutebrowser.utils import urlmatch
# Two open brackets (`[[`).
pytest.param(
"http://[[2607:f8b0:4005:805::200e]/*",
- r"""Expected '\]' to match '\[' in hostname; source was "\[2607:f8b0:4005:805::200e"; host = """"",
+ (
+ r'''Expected '\]' to match '\[' in hostname; source was "\[2607:f8b0:4005:805::200e"; host = ""|'''
+ r"'\[2607:f8b0:4005:805::200e' does not appear to be an IPv4 or IPv6 address"
+ ),
id='host-ipv6-two-open',
),
# Too few colons in the last chunk.
pytest.param(
"http://[2607:f8b0:4005:805:200e]/*",
- 'Invalid IPv6 address; source was "2607:f8b0:4005:805:200e"; host = ""',
+ _INVALID_IP_MESSAGE,
id='host-ipv6-colons',
),
# Non-hex piece.
pytest.param(
"http://[2607:f8b0:4005:805:200e:12:bogus]/*",
- 'Invalid IPv6 address; source was "2607:f8b0:4005:805:200e:12:bogus"; host = ""',
+ _INVALID_IP_MESSAGE,
id='host-ipv6-non-hex',
),
@@ -153,33 +166,33 @@ from qutebrowser.utils import urlmatch
pytest.param("http://[", "Invalid IPv6 URL", id='ipv6-single-open'),
pytest.param(
"http://[fc2e::bb88::edac]",
- 'Invalid IPv6 address; source was "fc2e::bb88::edac"; host = ""',
+ _INVALID_IP_MESSAGE,
id='ipv6-double-double',
),
pytest.param(
"http://[fc2e:0e35:bb88::edac:fc2e:0e35:bb88:edac]",
- 'Invalid IPv6 address; source was "fc2e:0e35:bb88::edac:fc2e:0e35:bb88:edac"; host = ""',
+ _INVALID_IP_MESSAGE,
id='ipv6-long-double',
),
pytest.param(
"http://[fc2e:0e35:bb88:af:edac:fc2e:0e35:bb88:edac]",
- 'Invalid IPv6 address; source was "fc2e:0e35:bb88:af:edac:fc2e:0e35:bb88:edac"; host = ""',
+ _INVALID_IP_MESSAGE,
id='ipv6-long',
),
pytest.param(
"http://[127.0.0.1:fc2e::bb88:edac]",
- r'Invalid IPv6 address; source was "127\.0\.0\.1:fc2e::bb88:edac',
+ _INVALID_IP_MESSAGE,
id='ipv6-ipv4',
),
pytest.param("http://[fc2e::bb88", "Invalid IPv6 URL", id='ipv6-trailing'),
pytest.param(
"http://[fc2e:bb88:edac]",
- 'Invalid IPv6 address; source was "fc2e:bb88:edac"; host = ""',
+ _INVALID_IP_MESSAGE,
id='ipv6-short',
),
pytest.param(
"http://[fc2e:bb88:edac::z]",
- 'Invalid IPv6 address; source was "fc2e:bb88:edac::z"; host = ""',
+ _INVALID_IP_MESSAGE,
id='ipv6-z',
),
pytest.param(
@@ -190,7 +203,7 @@ from qutebrowser.utils import urlmatch
pytest.param("://", "Missing scheme", id='scheme-naked'),
])
def test_invalid_patterns(pattern, error):
- with pytest.raises(urlmatch.ParseError, match=error):
+ with pytest.raises(urlmatch.ParseError, match=f"^{error}$"):
urlmatch.UrlPattern(pattern)
# pylint: enable=line-too-long