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
This commit is contained in:
Chris Mayo 2024-09-20 19:21:25 +01:00
parent dae72c8b11
commit 94839dcb03
4 changed files with 54 additions and 2 deletions

View file

@ -0,0 +1,7 @@
<a href="http://www.example.com/">ok example</a>
<a href="http:/www.example.com/">one slash example</a>
<a href="http:www.example.com/">no slash example</a>
<a href="//www.example.com/">no scheme example</a>
<a href="http://">no url</a>
<a href="http:/">no url, one slash</a>
<a href="http:">no url, no slash</a>

View file

@ -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

View file

@ -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

View file

@ -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):