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_compressed_ipv6():
url = URL("http://[1DEC:0:0:0::1]")
assert url.raw_host == "1dec::1"
assert url.host == url.raw_host
def test_from_str_with_host_ipv6():
url = URL("http://host:80")
url = url.with_host("::1")
assert url.raw_host == "::1"
def test_http_request_parser_non_utf8(parser) -> None:
text = 'GET /path HTTP/1.1\r\nx-test:тест\r\n\r\n'.encode('cp1251')
msg = parser.feed_data(text)[0][0][0]
assert msg.method == 'GET'
assert msg.path == '/path'
assert msg.version == (1, 1)
assert msg.headers == CIMultiDict([('X-TEST', 'тест'.encode('cp1251')
.decode('utf8', 'surrogateescape'))])
assert msg.raw_headers == ((b'x-test', 'тест'.encode('cp1251')),)
assert not msg.should_close
assert msg.compression is None
assert not msg.upgrade
assert not msg.chunked
assert msg.url == URL('/path')
def test_no_host(self):
with pytest.raises(ValueError):
URL("//:80")
def test_with_name_double_dot():
with pytest.raises(ValueError):
URL("http://example.com").with_name("..")
def test_build_with_port():
with pytest.raises(ValueError):
URL.build(port=8000)
u = URL.build(scheme="http", host="127.0.0.1", port=8000)
assert str(u) == "http://127.0.0.1:8000"
return st.builds (lambda x: URL.build (**x), args)
def test_build_with_host():
u = URL.build(host="127.0.0.1")
assert str(u) == "//127.0.0.1"
assert u == URL("//127.0.0.1")
def test_build_with_scheme_and_host():
u = URL.build(scheme="http", host="127.0.0.1")
assert str(u) == "http://127.0.0.1"
assert u == URL("http://127.0.0.1")
def test_build_with_port():
with pytest.raises(ValueError):
URL.build(port=8000)
u = URL.build(scheme="http", host="127.0.0.1", port=8000)
assert str(u) == "http://127.0.0.1:8000"