From db54fa3eebb5259a3794c23720d78d16cf70e71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20K=C3=B6tter?= Date: Fri, 14 Jun 2024 07:48:42 +0200 Subject: [PATCH] tests - extend tests for empty segments --- tests/test_url.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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", [