Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'yarl' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
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"