How to use yarl - 10 common examples

To help you get started, we’ve selected a few yarl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / yarl / tests / test_url.py View on Github external
def test_compressed_ipv6():
    url = URL("http://[1DEC:0:0:0::1]")
    assert url.raw_host == "1dec::1"
    assert url.host == url.raw_host
github aio-libs / yarl / tests / test_url_update_netloc.py View on Github external
def test_from_str_with_host_ipv6():
    url = URL("http://host:80")
    url = url.with_host("::1")
    assert url.raw_host == "::1"
github aio-libs / aiohttp / tests / test_http_parser.py View on Github external
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')
github aio-libs / yarl / tests / test_url_parsing.py View on Github external
def test_no_host(self):
        with pytest.raises(ValueError):
            URL("//:80")
github aio-libs / yarl / tests / test_url.py View on Github external
def test_with_name_double_dot():
    with pytest.raises(ValueError):
        URL("http://example.com").with_name("..")
github aio-libs / yarl / tests / test_url_build.py View on Github external
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"
github PromyLOPh / crocoite / crocoite / test_browser.py View on Github external
    return st.builds (lambda x: URL.build (**x), args)
github aio-libs / yarl / tests / test_url_build.py View on Github external
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")
github aio-libs / yarl / tests / test_url_build.py View on Github external
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")
github aio-libs / yarl / tests / test_url_build.py View on Github external
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"