예제 #1
0
def test_url_is_not_str():
    url = URL("http://example.com")
    assert not isinstance(url, str)
예제 #2
0
def test_origin():
    url = URL("http://*****:*****@example.com:8888/path/to?a=1&b=2")
    assert URL("http://example.com:8888") == url.origin()
예제 #3
0
def test_with_path_dots():
    url = URL("http://example.com")
    assert str(url.with_path("/test/.")) == "http://example.com/test/"
예제 #4
0
def test_div_for_relative_url():
    url = URL("a") / "b"
    assert url.raw_parts == ("a", "b")
예제 #5
0
def test_div_with_colon_and_at():
    url = URL("http://example.com/base") / "path:abc@123"
    assert url.raw_path == "/base/path:abc@123"
예제 #6
0
def test_div_with_slash():
    url = URL("http://example.com/path/")
    assert str(url / "to") == "http://example.com/path/to"
예제 #7
0
def test_div_cleanup_query_and_fragment():
    url = URL("http://example.com/path?a=1#frag")
    assert str(url / "to") == "http://example.com/path/to"
예제 #8
0
def test_plus_in_path():
    url = URL("http://example.com/test/x+y%2Bz/:+%2B/")
    assert "/test/x+y+z/:++/" == url.path
예제 #9
0
def test_parent_raw_parts():
    url = URL("http://example.com/path/to")
    assert url.parent.raw_parts == ("/", "path")
예제 #10
0
def test_relative_raw_name_slash():
    url = URL("/")
    assert "" == url.raw_name
예제 #11
0
def test_name_non_ascii():
    url = URL("http://example.com/путь")
    assert url.name == "путь"
예제 #12
0
def test_relative_raw_name_starting_from_slash():
    url = URL("/path/to")
    assert "to" == url.raw_name
예제 #13
0
def test_relative_raw_name():
    url = URL("path/to")
    assert "to" == url.raw_name
예제 #14
0
def test_raw_name_root3():
    url = URL("http://example.com/")
    assert "" == url.raw_name
예제 #15
0
def test_div():
    url = URL("http://example.com/path")
    assert str(url / "to") == "http://example.com/path/to"
예제 #16
0
def test_double_parent_raw_path():
    url = URL("http://example.com/path/to")
    assert url.parent.parent.raw_path == "/"
예제 #17
0
def test_repr():
    url = URL("http://example.com")
    assert "URL('http://example.com')" == repr(url)
예제 #18
0
def test_str():
    url = URL("http://example.com:8888/path/to?a=1&b=2")
    assert str(url) == "http://example.com:8888/path/to?a=1&b=2"
예제 #19
0
def test_div_path_starting_from_slash_is_forbidden():
    url = URL("http://example.com/path/")
    with pytest.raises(ValueError):
        url / "/to/others"
예제 #20
0
def test_empty_parent_raw_path2():
    url = URL("http://example.com")
    assert url.parent.parent.raw_path == "/"
예제 #21
0
def test_div_for_empty_url():
    url = URL() / "a"
    assert url.raw_parts == ("a", )
예제 #22
0
def test_clear_fragment_on_getting_parent():
    url = URL("http://example.com/path/to#frag")
    assert URL("http://example.com/path") == url.parent
예제 #23
0
def test_div_for_relative_url_started_with_slash():
    url = URL("/a") / "b"
    assert url.raw_parts == ("/", "a", "b")
예제 #24
0
def test_clear_fragment_on_getting_parent_toplevel():
    url = URL("http://example.com/#frag")
    assert URL("http://example.com/") == url.parent
예제 #25
0
def test_div_with_dots():
    url = URL("http://example.com/base") / "../path/./to"
    assert url.raw_path == "/path/to"
예제 #26
0
def test_clear_query_on_getting_parent():
    url = URL("http://example.com/path/to?a=b")
    assert URL("http://example.com/path") == url.parent
예제 #27
0
def test_with_path_encoded():
    url = URL("http://example.com")
    assert str(url.with_path("/test",
                             encoded=True)) == "http://example.com/test"
예제 #28
0
def test_clear_query_on_getting_parent_toplevel():
    url = URL("http://example.com/?a=b")
    assert URL("http://example.com/") == url.parent
예제 #29
0
def test_with_path_relative():
    url = URL("/path")
    assert str(url.with_path("/new")) == "/new"
예제 #30
0
def test_raw_name():
    url = URL("http://example.com/path/to#frag")
    assert "to" == url.raw_name