Skip to content

Commit 6a2a90a

Browse files
authored
Add xfail tests for URL subtraction with empty segments (#1390)
1 parent f0b8db7 commit 6a2a90a

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

tests/test_url.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ def test_str():
6666
[
6767
("http://example.com/path/to", "http://example.com/", "path/to"),
6868
("http://example.com/path/to", "http://example.com/spam", "path/to"),
69-
(
70-
"http://example.com/////path/////to",
71-
"http://example.com/////spam",
72-
"path/to",
73-
),
7469
("http://example.com/this/is/a/test", "http://example.com/this/", "is/a/test"),
7570
(
7671
"http://example.com/this/./is/a/test",
@@ -103,6 +98,28 @@ def test_sub(target: str, base: str, expected: str):
10398
assert result_url == expected_url
10499

105100

101+
@pytest.mark.xfail(reason="Empty segments are not preserved")
102+
@pytest.mark.parametrize(
103+
("target", "base", "expected"),
104+
[
105+
(
106+
"http://example.com/////path/////to",
107+
"http://example.com/////spam",
108+
"path/////to",
109+
),
110+
(
111+
"http://example.com////path/////to",
112+
"http://example.com/////spam",
113+
"..//path/////to",
114+
),
115+
],
116+
)
117+
def test_sub_empty_segments(target: str, base: str, expected: str):
118+
expected_url = URL(expected)
119+
result_url = URL(target) - URL(base)
120+
assert result_url == expected_url
121+
122+
106123
def test_sub_with_different_schemes():
107124
expected_error_msg = "Both URLs should have the same scheme"
108125
with pytest.raises(ValueError, match=expected_error_msg):

0 commit comments

Comments
 (0)