From 8341a597fb3dbf1992d7fc57411c743ce82a2309 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 8 Oct 2024 12:39:21 +0200 Subject: [PATCH] Add test coverage for handling port 0 This was wrong in previous yarl releases, but fixed by one of the cleanups in 1.14.0. Add coverage to make sure it continutes to work as 0 is not a default port --- tests/test_url.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/test_url.py b/tests/test_url.py index edca232d..25132666 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -334,14 +334,6 @@ def test_explicit_port_for_implicit_port(): assert url._port_not_default is None -def test_handling_port_zero(): - url = URL("http://example.com:0") - assert url.explicit_port == 0 - assert url.explicit_port == url._val.port - assert url._port_not_default == 0 - assert str(url) == "http://example.com:0" - - def test_explicit_port_for_relative_url(): url = URL("/path/to") assert url.explicit_port is None @@ -1494,6 +1486,15 @@ def test_is_default_port_for_unknown_scheme(): assert not url.is_default_port() +def test_handling_port_zero(): + url = URL("http://example.com:0") + assert url.explicit_port == 0 + assert url.explicit_port == url._val.port + assert url._port_not_default == 0 + assert str(url) == "http://example.com:0" + assert not url.is_default_port() + + #