diff --git a/tests/test_url.py b/tests/test_url.py index 91f20a689..cad37a3c0 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -851,7 +851,8 @@ def test_joinpath(base, to_join, expected): pytest.param("path//", "a", "path//a", id="empty-segments_default"), pytest.param("path//", "./a", "path//a", id="empty-segments_relative"), pytest.param("path//", ".//a", "path///a", id="empty-segments_empty-segment"), - pytest.param("path", "a//", "path/a//", id="default_trailing-empty-segment"), + pytest.param("path", "a/", "path/a/", id="default_trailing-empty-segment"), + pytest.param("path", "a//", "path/a//", id="default_trailing-empty-segments"), pytest.param("path", "a//b", "path/a//b", id="default_embedded-empty-segment"), ], ) @@ -860,6 +861,14 @@ def test_joinpath_empty_segments(base, to_join, expected): assert str(url.joinpath(to_join)) == f"http://example.com/{expected}" +def test_joinpath_single_empty_segments(): + """joining standalone empty segments does not create empty segments""" + a = URL("/1//2///3") + assert a.parts == ("/", "1", "", "2", "", "", "3") + b = URL("scheme://host").joinpath(*a.parts[1:]) + assert b.path == "/1/2/3" + + @pytest.mark.parametrize( "url,to_join,expected", [