def test_uri_empty_port_is_0(): uri = URI("://foobar:[email protected]:8080/baz.html?buz=bloo") assert uri.port == 0, uri.port
def test_uri_empty_password_is_empty_unicode(): uri = URI("http://foobar:@www.example.com:8080/baz.html?buz=bloo") assert uri.password == u"", uri.password assert isinstance(uri.password, unicode), uri.password.__class__
def test_uri_empty_host_is_empty_unicode(): uri = URI("http://*****:*****@:8080/baz.html?buz=bloo") assert uri.host == u"", uri.host assert isinstance(uri.host, unicode), uri.host.__class__
def test_a_nice_unicode_uri(): uri = URI("http://%E2%98%84:bar@localhost:5370/+%E2%98%84.html?%E2%98%84=%E2%98%84+bar") assert uri == "http://%E2%98%84:bar@localhost:5370/+%E2%98%84.html?%E2%98%84=%E2%98%84+bar", uri
def test_uri_empty_username_is_empty_unicode(): uri = URI("http://:[email protected]:8080/baz.html?buz=bloo") assert uri.username == u"", uri.username assert isinstance(uri.username, unicode), uri.username.__class__
def test_uri_encoded_username_is_unencoded_properly(): uri = URI("http://%e2%98%84:[email protected]/foo.html") assert uri.username == u'\u2604', uri.username
def test_uri_international_domain_name_comes_out_properly(): uri = URI("http://www.xn--cev.tk/foo.html") assert uri.host == u'www.\u658b.tk', uri.host
def test_uri_sets_querystring(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert uri.querystring.decoded == u"buz=bloo", uri.querystring.decoded
def test_uri_host_is_unicode(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert isinstance(uri.host, unicode)
def test_uri_sets_port(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert uri.port == 8080, uri.port
def test_uri_sets_path(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert uri.path.decoded == u"/baz.html", uri.path.decoded
def test_uri_sets_host(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert uri.host == u"www.example.com", uri.host
def test_uri_sets_password(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert uri.password == u"secret", uri.password
def test_uri_sets_username(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert uri.username == u"foobar", uri.username
def test_uri_normal_case_is_normal(): uri = URI("/baz.html?buz=bloo") assert uri.path == Path("/baz.html") assert uri.querystring == Querystring("buz=bloo")
def test_uri_port_is_int(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert isinstance(uri.port, int)
def test_uri_ASCII_worketh(): uri = URI(chr(127)) assert uri == unichr(127), uri
def test_uri_querystring_is_Mapping(): uri = URI("http://*****:*****@www.example.com:8080/baz.html?buz=bloo") assert isinstance(uri.querystring, Mapping)
def test_uri_encoded_password_is_unencoded_properly(): uri = URI("http://*****:*****@www.example.com/foo.html") assert uri.password == u'\u2604', uri.password
def test_uri_empty_scheme_is_empty_unicode(): uri = URI("://foobar:[email protected]:8080/baz.html?buz=bloo") assert uri.scheme == u"", uri.scheme assert isinstance(uri.scheme, unicode), uri.scheme.__class__
def test_uri_raw_is_available_on_something(): uri = URI("http://www.xn--cev.tk/") assert uri.host.raw == "www.xn--cev.tk", uri.host.raw
def test_uri_works_at_all(): uri = URI("/") expected = u"/" actual = uri assert actual == expected, actual