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_uri_with_everything(self, uri_with_everything):
uri = pr.ParseResult.from_string(uri_with_everything)
assert uri.host == uri.hostname
assert uri.netloc == uri.authority
assert uri.query == uri.params
assert uri.geturl() == uri.unsplit()
def test_from_parts(parts, unsplit):
uri = pr.ParseResult.from_parts(*parts)
assert uri.unsplit() == unsplit
b"https://httpbin.org:443/get",
),
(("HTTPS", None, "HTTPBIN.ORG"), b"https://httpbin.org"),
],
)
def test_bytes_from_parts(parts, unsplit):
uri = pr.ParseResultBytes.from_parts(*parts)
assert uri.unsplit() == unsplit
class TestParseResultParsesURIs(base.BaseTestParsesURIs):
test_class = pr.ParseResult
class TestParseResultUnsplits(base.BaseTestUnsplits):
test_class = pr.ParseResult
def test_normalizes_uris_when_using_from_string(uri_to_normalize):
"""Verify we always get the same thing out as we expect."""
result = pr.ParseResult.from_string(
uri_to_normalize, lazy_normalize=False
)
assert result.scheme == "https"
assert result.host == "example.com"
class TestStdlibShims:
def test_uri_with_everything(self, uri_with_everything):
uri = pr.ParseResult.from_string(uri_with_everything)
assert uri.host == uri.hostname
assert uri.netloc == uri.authority
def test_creates_a_copy_with_a_new_path(uri_with_everything):
uri = pr.ParseResult.from_string(uri_with_everything)
new_uri = uri.copy_with(path="/parse/result/tests/are/fun")
assert new_uri.path == "/parse/result/tests/are/fun"
def test_strict_urlparsing():
with pytest.raises(exceptions.InvalidAuthority):
parseresult.ParseResult.from_string(SNOWMAN_HOST)