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'
def test_path_as_ref_absolute(): assert path_as_href('/foo/bar/baz') == '/foo/bar/baz'
def test_path_as_ref_relative(): assert path_as_href('../bar/baz') == '../bar/baz'
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'
def test_path_as_ref_special_characters(): assert path_as_href('/a dir/a file!.md') == '/a%20dir/a%20file%21.md'
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)
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'
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'