Beispiel #1
0
    def test_protocol_relative_shortcut(self, instance):
        https = URI("https://")

        instance = https // instance
        assert str(
            instance
        ) == "https://*****:*****@example.com/over/there?name=ferret#anchor"
Beispiel #2
0
    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]
Beispiel #3
0
    def test_rootless_path_authority_error(self):
        uri = URI('http://example.com')

        with pytest.raises(ValueError):
            uri.path = 'foo/bar'
Beispiel #4
0
 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"
Beispiel #5
0
 def test_path_usage(self):
     path = Path("/foo/bar/baz")
     instance = URI(path)
     assert instance.scheme == 'file'
     assert str(instance) == "file:///foo/bar/baz"
Beispiel #6
0
    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"
Beispiel #7
0
 def test_empty(self):
     instance = URI()
     assert str(instance) == ""
     assert not instance
Beispiel #8
0
 def test_uri_error(self):
     with pytest.raises(TypeError):
         URI(foo="bar")
Beispiel #9
0
 def test_length(self, string, attributes):
     instance = URI(string)
     assert len(instance) == len(string)
Beispiel #10
0
 def test_identity_comparison(self, string, attributes):
     instance = URI(string)
     assert instance == attributes['uri']
Beispiel #11
0
 def test_inverse_bad_comparison(self, string, attributes):
     instance = URI(string)
     assert instance != "fnord"
Beispiel #12
0
 def test_identity_bytes(self, string, attributes):
     instance = URI(string)
     assert bytes(instance) == attributes['uri'].encode('utf-8')
Beispiel #13
0
 def test_identity(self, string, attributes):
     instance = URI(string)
     assert str(instance) == attributes['uri']
Beispiel #14
0
 def test_truthiness(self, string, attributes):
     instance = URI(string)
     assert instance
Beispiel #15
0
def empty():
    return URI('http://example.com/over/there')
Beispiel #16
0
def instance():
    return URI('http://*****:*****@example.com/over/there?name=ferret#anchor')