Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_eager_normalization_from_string(self):
uri = pr.ParseResultBytes.from_string(
b"http://" + SNOWMAN + b".com/path",
strict=False,
lazy_normalize=False,
)
assert uri.unsplit() == b"http:/path"
def test_unsplit(self):
uri = pr.ParseResultBytes.from_string(
b"http://" + SNOWMAN + b".com/path", strict=False
)
idna_encoded = SNOWMAN_IDNA_HOST.encode("utf-8") + b"/path"
assert uri.unsplit(use_idna=True) == idna_encoded
def test_copy_with_a_new_unicode_path(self, uri_with_everything):
uri = pr.ParseResultBytes.from_string(uri_with_everything)
pathbytes = b"/parse/result/tests/are/fun" + SNOWMAN
new_uri = uri.copy_with(path=pathbytes.decode("utf-8"))
assert new_uri.path == (b"/parse/result/tests/are/fun" + SNOWMAN)
def test_handles_uri_with_everything(self, uri_with_everything):
uri = pr.ParseResultBytes.from_string(uri_with_everything)
assert uri.scheme == b"https"
assert uri.path == b"/path/to/resource"
assert uri.query == b"key=value"
assert uri.fragment == b"fragment"
assert uri.userinfo == b"user:pass"
assert uri.port == 443
assert isinstance(uri.authority, bytes) is True
def test_raises_invalid_authority_for_invalid_uris(self, invalid_uri):
with pytest.raises(exceptions.InvalidAuthority):
pr.ParseResultBytes.from_string(invalid_uri)
def test_copy_with_a_new_path(self, uri_with_everything):
uri = pr.ParseResultBytes.from_string(uri_with_everything)
new_uri = uri.copy_with(path=b"/parse/result/tests/are/fun")
assert new_uri.path == b"/parse/result/tests/are/fun"