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_parse_result_encodes_itself(uri_with_everything):
uri = pr.ParseResult.from_string(uri_with_everything)
uribytes = uri.encode()
encoding = uri.encoding
assert uri.scheme.encode(encoding) == uribytes.scheme
assert uri.userinfo.encode(encoding) == uribytes.userinfo
assert uri.host.encode(encoding) == uribytes.host
assert uri.port == uribytes.port
assert uri.path.encode(encoding) == uribytes.path
assert uri.query.encode(encoding) == uribytes.query
assert uri.fragment.encode(encoding) == uribytes.fragment
def test_raises_invalid_port_non_strict_parse(self, port):
with pytest.raises(exceptions.InvalidPort):
pr.ParseResultBytes.from_string(
"https://httpbin.org:{0}/get".format(port), strict=False
)