def test_protocol_relative_shortcut(self, instance): https = URI("https://") instance = https // instance assert str( instance ) == "https://*****:*****@example.com/over/there?name=ferret#anchor"
def test_component(self, string, attributes, component): instance = URI(string) value = getattr(instance, component, SENTINEL) if component not in attributes: assert value in (None, SENTINEL, '') return assert value == attributes[component]
def test_rootless_path_authority_error(self): uri = URI('http://example.com') with pytest.raises(ValueError): uri.path = 'foo/bar'
def test_rooted_path_authority_resolution(self): uri = URI('http://example.com/diz') uri.path = '/foo/bar' assert str(uri) == "http://example.com/foo/bar"
def test_path_usage(self): path = Path("/foo/bar/baz") instance = URI(path) assert instance.scheme == 'file' assert str(instance) == "file:///foo/bar/baz"
def test_qs_assignment(self): instance = URI("http://example.com") assert str(instance) == "http://example.com/" instance.qs = "foo=bar" assert str(instance) == "http://example.com/?foo=bar"
def test_empty(self): instance = URI() assert str(instance) == "" assert not instance
def test_uri_error(self): with pytest.raises(TypeError): URI(foo="bar")
def test_length(self, string, attributes): instance = URI(string) assert len(instance) == len(string)
def test_identity_comparison(self, string, attributes): instance = URI(string) assert instance == attributes['uri']
def test_inverse_bad_comparison(self, string, attributes): instance = URI(string) assert instance != "fnord"
def test_identity_bytes(self, string, attributes): instance = URI(string) assert bytes(instance) == attributes['uri'].encode('utf-8')
def test_identity(self, string, attributes): instance = URI(string) assert str(instance) == attributes['uri']
def test_truthiness(self, string, attributes): instance = URI(string) assert instance
def empty(): return URI('http://example.com/over/there')
def instance(): return URI('http://*****:*****@example.com/over/there?name=ferret#anchor')