Esempio n. 1
0
def test_can_parse_empty_path():
    path = Path("")
    assert str(path) == ""
    assert path.string == ""
Esempio n. 2
0
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"
Esempio n. 3
0
def test_can_parse_none_path():
    path = Path(None)
    assert str(path) == ""
    assert path.string is None
Esempio n. 4
0
def test_path_equality_when_none():
    path = Path(None)
    none = None
    assert path == none
Esempio n. 5
0
def test_path_has_no_segments_when_none():
    path = Path(None)
    segments = list(path.segments)
    assert segments == []
Esempio n. 6
0
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"
Esempio n. 7
0
def test_path_inequality():
    path1 = Path("/foo/bar")
    path2 = Path("/foo/bar/baz")
    assert path1 != path2
Esempio n. 8
0
def test_can_add_trailing_slash_to_empty_path():
    path = Path("")
    path = path.with_trailing_slash()
    assert path.string == "/"
Esempio n. 9
0
def test_cant_add_trailing_slash_to_none_path():
    path = Path(None)
    path = path.with_trailing_slash()
    assert path.string is None
Esempio n. 10
0
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/"
Esempio n. 11
0
def test_wont_add_trailing_slash_to_root_path():
    path = Path("/")
    path = path.with_trailing_slash()
    assert path.string == "/"
Esempio n. 12
0
def test_can_add_trailing_slash_to_path():
    path = Path("/foo/bar")
    path = path.with_trailing_slash()
    assert path.string == "/foo/bar/"
Esempio n. 13
0
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"
Esempio n. 14
0
def test_can_remove_dot_segments_when_single_dot():
    path_in = Path(".")
    path_out = path_in.remove_dot_segments()
    assert path_out == ""
Esempio n. 15
0
def test_can_parse_absolute_path():
    path = Path("/foo/bar")
    assert str(path) == "/foo/bar"
    assert path.string == "/foo/bar"
Esempio n. 16
0
def test_can_remove_trailing_slash_from_path():
    path = Path("/foo/bar/")
    path = path.without_trailing_slash()
    assert path.string == "/foo/bar"
Esempio n. 17
0
def test_can_parse_relative_path():
    path = Path("foo/bar")
    assert str(path) == "foo/bar"
    assert path.string == "foo/bar"
Esempio n. 18
0
def test_wont_remove_trailing_slash_if_none_exists():
    path = Path("/foo/bar")
    path = path.without_trailing_slash()
    assert path.string == "/foo/bar"
Esempio n. 19
0
def test_path_equality():
    path1 = Path("/foo/bar")
    path2 = Path("/foo/bar")
    assert path1 == path2
Esempio n. 20
0
def test_will_remove_root_path_slash():
    path = Path("/")
    path = path.without_trailing_slash()
    assert path.string == ""
Esempio n. 21
0
def test_path_equality_with_string_containing_encoded_space():
    path = Path("/foo bar")
    string = "/foo%20bar"
    assert path == string
Esempio n. 22
0
def test_cannot_remove_trailing_slash_from_empty_string():
    path = Path("")
    path = path.without_trailing_slash()
    assert path.string == ""
Esempio n. 23
0
def test_path_is_hashable():
    path = Path("/foo/bar")
    hashed = hash(path)
    assert hashed
Esempio n. 24
0
def test_cannot_remove_trailing_slash_from_none_path():
    path = Path(None)
    path = path.without_trailing_slash()
    assert path.string is None
Esempio n. 25
0
def test_path_is_iterable_as_segments():
    path = Path("/foo/bar")
    segments = list(path)
    assert segments == ["", "foo", "bar"]
Esempio n. 26
0
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"