コード例 #1
0
def test_path_as_ref_absolute_into_url():
    parts = urlparse('/foo/bar/baz#f?k=v')
    assert path_as_href('/meh/ok', parts) == '/meh/ok#f?k=v'
コード例 #2
0
def test_path_as_ref_absolute():
    assert path_as_href('/foo/bar/baz') == '/foo/bar/baz'
コード例 #3
0
def test_path_as_ref_relative():
    assert path_as_href('../bar/baz') == '../bar/baz'
コード例 #4
0
def test_path_as_ref_special_characters_into_url():
    parts = urlparse('/foo/bar/baz#f?k=v')
    assert path_as_href('/a dir/a file!.md',
                        parts) == '/a%20dir/a%20file%21.md#f?k=v'
コード例 #5
0
def test_path_as_ref_special_characters():
    assert path_as_href('/a dir/a file!.md') == '/a%20dir/a%20file%21.md'
コード例 #6
0
def test_path_as_ref_relative_into_url_with_scheme():
    parts = urlparse('file://localhost/foo/bar/baz')
    with pytest.raises(ValueError):
        path_as_href('../meh/ok', parts)
コード例 #7
0
def test_path_as_ref_absolute_into_url_with_scheme():
    parts = urlparse('file://localhost/foo/bar/baz')
    assert path_as_href('/meh/ok', parts) == 'file://localhost/meh/ok'
コード例 #8
0
def test_path_as_ref_relative_into_url():
    parts = urlparse('/foo/bar/baz#f?k=v')
    assert path_as_href('../meh/ok', parts) == '../meh/ok#f?k=v'