def test_can_parse_empty_path(): path = Path("") assert str(path) == "" assert path.string == ""
def test_can_remove_dot_segments_pattern_2(): path_in = Path("mid/content=5/../6") path_out = path_in.remove_dot_segments() assert path_out == "mid/6"
def test_can_parse_none_path(): path = Path(None) assert str(path) == "" assert path.string is None
def test_path_equality_when_none(): path = Path(None) none = None assert path == none
def test_path_has_no_segments_when_none(): path = Path(None) segments = list(path.segments) assert segments == []
def test_can_parse_path_with_encoded_slash(): path = Path("/foo/bar%2Fbaz") assert str(path) == "/foo/bar%2Fbaz" assert path.string == "/foo/bar%2Fbaz"
def test_path_inequality(): path1 = Path("/foo/bar") path2 = Path("/foo/bar/baz") assert path1 != path2
def test_can_add_trailing_slash_to_empty_path(): path = Path("") path = path.with_trailing_slash() assert path.string == "/"
def test_cant_add_trailing_slash_to_none_path(): path = Path(None) path = path.with_trailing_slash() assert path.string is None
def test_wont_add_trailing_slash_to_path_that_already_has_one(): path = Path("/foo/bar/") path = path.with_trailing_slash() assert path.string == "/foo/bar/"
def test_wont_add_trailing_slash_to_root_path(): path = Path("/") path = path.with_trailing_slash() assert path.string == "/"
def test_can_add_trailing_slash_to_path(): path = Path("/foo/bar") path = path.with_trailing_slash() assert path.string == "/foo/bar/"
def test_can_remove_dot_segments_when_starts_with_double_dot(): path_in = Path("../a") path_out = path_in.remove_dot_segments() assert path_out == "a"
def test_can_remove_dot_segments_when_single_dot(): path_in = Path(".") path_out = path_in.remove_dot_segments() assert path_out == ""
def test_can_parse_absolute_path(): path = Path("/foo/bar") assert str(path) == "/foo/bar" assert path.string == "/foo/bar"
def test_can_remove_trailing_slash_from_path(): path = Path("/foo/bar/") path = path.without_trailing_slash() assert path.string == "/foo/bar"
def test_can_parse_relative_path(): path = Path("foo/bar") assert str(path) == "foo/bar" assert path.string == "foo/bar"
def test_wont_remove_trailing_slash_if_none_exists(): path = Path("/foo/bar") path = path.without_trailing_slash() assert path.string == "/foo/bar"
def test_path_equality(): path1 = Path("/foo/bar") path2 = Path("/foo/bar") assert path1 == path2
def test_will_remove_root_path_slash(): path = Path("/") path = path.without_trailing_slash() assert path.string == ""
def test_path_equality_with_string_containing_encoded_space(): path = Path("/foo bar") string = "/foo%20bar" assert path == string
def test_cannot_remove_trailing_slash_from_empty_string(): path = Path("") path = path.without_trailing_slash() assert path.string == ""
def test_path_is_hashable(): path = Path("/foo/bar") hashed = hash(path) assert hashed
def test_cannot_remove_trailing_slash_from_none_path(): path = Path(None) path = path.without_trailing_slash() assert path.string is None
def test_path_is_iterable_as_segments(): path = Path("/foo/bar") segments = list(path) assert segments == ["", "foo", "bar"]
def test_can_remove_dot_segments_pattern_1(): path_in = Path("/a/b/c/./../../g") path_out = path_in.remove_dot_segments() assert path_out == "/a/g"