Skip to content

Commit

Permalink
Add xfail tests for URL subtraction with empty segments
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Oct 25, 2024
1 parent f0b8db7 commit 3964744
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 3964744

Please sign in to comment.