From 94839dcb03947af6020a74af639fc7f9408ae24e Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Fri, 20 Sep 2024 19:21:25 +0100 Subject: [PATCH] Fix TestHttp.test_html_internet on Python 3.12.6 A relative path in a URL without netloc is preserved in urllib.parse.urlunsplit(). https://docs.python.org/3.12/whatsnew/changelog.html#id4 --- .../data/http_slash-old-urlunsplit.html | 7 ++++ .../http_slash-old-urlunsplit.html.result | 40 +++++++++++++++++++ tests/checker/data/http_slash.html.result | 2 +- tests/checker/test_http.py | 7 +++- 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/checker/data/http_slash-old-urlunsplit.html create mode 100644 tests/checker/data/http_slash-old-urlunsplit.html.result diff --git a/tests/checker/data/http_slash-old-urlunsplit.html b/tests/checker/data/http_slash-old-urlunsplit.html new file mode 100644 index 00000000..b507fca3 --- /dev/null +++ b/tests/checker/data/http_slash-old-urlunsplit.html @@ -0,0 +1,7 @@ +ok example +one slash example +no slash example +no scheme example +no url +no url, one slash +no url, no slash diff --git a/tests/checker/data/http_slash-old-urlunsplit.html.result b/tests/checker/data/http_slash-old-urlunsplit.html.result new file mode 100644 index 00000000..b55ee2ab --- /dev/null +++ b/tests/checker/data/http_slash-old-urlunsplit.html.result @@ -0,0 +1,40 @@ +url http://localhost:%(port)d/%(datadir)s/http_slash-old-urlunsplit.html +cache key http://localhost:%(port)d/%(datadir)s/http_slash-old-urlunsplit.html +real url http://localhost:%(port)d/%(datadir)s/http_slash-old-urlunsplit.html +valid + +url http: +cache key None +real url http:// +name no url, no slash +error + +url http:/ +cache key None +real url http:/// +name no url, one slash +error + +url http:// +cache key None +real url http:// +name no url +error + +url http:www.example.com/ +cache key None +real url http:///www.example.com/ +name no slash example +error + +url http:/www.example.com/ +cache key None +real url http:///www.example.com/ +name one slash example +error + +url http://www.example.com/ +cache key http://www.example.com/ +real url http://www.example.com/ +name ok example +valid diff --git a/tests/checker/data/http_slash.html.result b/tests/checker/data/http_slash.html.result index 837bf676..4766f20e 100644 --- a/tests/checker/data/http_slash.html.result +++ b/tests/checker/data/http_slash.html.result @@ -23,7 +23,7 @@ error url http:www.example.com/ cache key None -real url http:///www.example.com/ +real url http:www.example.com/ name no slash example error diff --git a/tests/checker/test_http.py b/tests/checker/test_http.py index 23ba6dad..d191fb00 100644 --- a/tests/checker/test_http.py +++ b/tests/checker/test_http.py @@ -16,6 +16,7 @@ """ Test http checking. """ +import sys from tests import need_network from .httpserver import HttpServerTest, CookieRedirectHttpRequestHandler @@ -34,7 +35,11 @@ class TestHttp(HttpServerTest): self.file_test("http.html", confargs=confargs) self.file_test("http_lowercase.html", confargs=confargs) self.file_test("http_quotes.html", confargs=confargs) - self.file_test("http_slash.html", confargs=confargs) + if sys.version_info < (3, 12, 6): + http_slash_html = "http_slash-old-urlunsplit.html" + else: + http_slash_html = "http_slash.html" + self.file_test(http_slash_html, confargs=confargs) self.file_test("http_url_quote.html", confargs=confargs) def test_html(self):