def test_update_keywords(self): instance = QSO("key=value1&key=value2&bar=baz") instance.update(bar="diz") assert str(instance) == "key=value1&key=value2&bar=diz" instance.update(diz="doz") assert str(instance) == "key=value1&key=value2&bar=diz&diz=doz" instance.update(key="value3") assert str(instance) == "bar=diz&diz=doz&key=value3"
def test_set_new(self, instance, empty): instance['foo'] = 'bar' assert str( instance ) == 'http://*****:*****@example.com/over/there?name=ferret&foo=bar#anchor' empty['bar'] = 'baz' assert str(empty) == 'http://example.com/over/there?bar=baz'
def test_insert(self): instance = QSO("foo&bar&baz") instance.insert(0, "diz") assert str(instance) == "diz&foo&bar&baz" instance.insert(-1, "doz") assert str(instance) == "diz&foo&bar&doz&baz" assert len(instance.groups[None]) == 5 instance.insert(99, "twentyseven") assert str(instance) == "diz&foo&bar&doz&baz&twentyseven"
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_numeric_deletion(self): instance = QSO('key=value1&key=value2&bar=baz') assert len(instance) == 3 assert len(instance.groups['key']) == 2 del instance[0] assert len(instance) == 2 assert len(instance.groups['key']) == 1 assert str(instance) == 'key=value2&bar=baz'
def test_reverse(self): instance = QSO("key=value1&key=value2&bar=baz") instance.reverse() assert str(instance) == "bar=baz&key=value2&key=value1" assert tuple(instance['key']) == ("value2", "value1")
def test_empty(self): instance = URI() assert str(instance) == "" assert not instance
def test_set_replace(self, instance): instance['name'] = 'lemur' assert str( instance ) == 'http://*****:*****@example.com/over/there?name=lemur#anchor'
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_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_relative_assignment(self, instance): instance /= "bar" assert str(instance) == "http://*****:*****@example.com/over/bar"
def test_resolution_overriding(self, instance): expect = "http://example.com/over/there?name=ferret#anchor" assert str(instance.resolve(user=None, password=None)) == expect
def test_rooted(self, instance): instance = instance / "/foo" assert str(instance) == "http://*****:*****@example.com/foo"
def test_pop_examples(self, src, key, expect, value): instance = QSO(src) result = instance.pop(key) assert str(instance) == expect assert result == value
def test_deletion_examples(self, src, key, expect, value): instance = QSO(src) del instance[key] assert str(instance) == expect
def test_inline_add(self, src, change, expect): instance = QSO(src) instance += change assert str(instance) == expect
def test_update(self, src, change, expect): instance = QSO(src) instance.update(change) assert str(instance) == expect
def test_relative(self, instance): instance = instance / "foo" assert str(instance) == "http://*****:*****@example.com/over/foo"
def test_str(self, string, args, kw): instance = QSO(string) assert str(instance) == string
def test_resolution_by_uri(self, instance): assert str( instance.resolve('/baz')) == "http://*****:*****@example.com/baz" assert str( instance.resolve('baz')) == "http://*****:*****@example.com/over/baz"
def test_named_assignment(self, string, args, kw): instance = QSO(string) instance['doz'] = '27' assert str(instance).endswith(('&' if (args or kw) else '') + 'doz=27')
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_grouped_replacement(self, string, args, kw): instance = QSO(string) instance['foo'] = 'doz' assert 'foo=doz' in str(instance)
def test_empty_protocol_assignment(self, empty): assert empty.scheme == 'http' empty.scheme = None assert str(empty) == "//example.com/over/there"
def test_string_identity(self, string, args, name, value, valid): bucket = Bucket(string) assert str(bucket) == string
def test_repr(self, string, args, name, value, valid): bucket = Bucket(*args) assert repr(bucket) == "Bucket(" + str(bucket) + ")"
def test_identity(self, string, attributes): instance = URI(string) assert str(instance) == attributes['uri']
def test_del(self, instance): del instance['name'] assert str( instance) == 'http://*****:*****@example.com/over/there#anchor'
def test_multiple_reassignment(self, src, key, value, expect): instance = QSO(src) instance[key] = value assert str(instance) == expect