diff --git a/tests/test_url.py b/tests/test_url.py index 0bd4158d2..444a9f565 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -66,11 +66,6 @@ def test_str(): [ ("http://example.com/path/to", "http://example.com/", "path/to"), ("http://example.com/path/to", "http://example.com/spam", "path/to"), - ( - "http://example.com/////path/////to", - "http://example.com/////spam", - "path/to", - ), ("http://example.com/this/is/a/test", "http://example.com/this/", "is/a/test"), ( "http://example.com/this/./is/a/test", @@ -103,6 +98,28 @@ def test_sub(target: str, base: str, expected: str): assert result_url == expected_url +@pytest.mark.xfail(reason="Empty segments are not preserved") +@pytest.mark.parametrize( + ("target", "base", "expected"), + [ + ( + "http://example.com/////path/////to", + "http://example.com/////spam", + "path/////to", + ), + ( + "http://example.com////path/////to", + "http://example.com/////spam", + "..//path/////to", + ), + ], +) +def test_sub_empty_segments(target: str, base: str, expected: str): + expected_url = URL(expected) + result_url = URL(target) - URL(base) + assert result_url == expected_url + + def test_sub_with_different_schemes(): expected_error_msg = "Both URLs should have the same scheme" with pytest.raises(ValueError, match=expected_error_msg):