Skip to content

Commit

Permalink
tests - extend tests for empty segments
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Jun 14, 2024
1 parent 3c7c590 commit db54fa3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
],
)
Expand All @@ -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",
[
Expand Down

0 comments on commit db54fa3

Please sign in to comment.