Skip to content

Commit

Permalink
Add test coverage for handling port 0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bdraco committed Oct 8, 2024
1 parent de509d0 commit 8341a59
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()


#


Expand Down

0 comments on commit 8341a59

Please sign in to comment.