Skip to content
Myr

test_url.py

This file

Path

tests/models/test_url.py

44 lines · 1.3 KiB · Python

Last changed by

query_params -> paramsTom Christiebefore adoptionbb70377

History of this file

Take it

1from httpcore import URL234def test_idna_url():5    url = URL("http://中国.icom.museum:80/")6    assert url == URL("http://xn--fiqs8s.icom.museum:80/")7    assert url.host == "xn--fiqs8s.icom.museum"8910def test_url():11    url = URL("https://example.org:123/path/to/somewhere?abc=123#anchor")12    assert url.scheme == "https"13    assert url.host == "example.org"14    assert url.port == 12315    assert url.authority == "example.org:123"16    assert url.path == "/path/to/somewhere"17    assert url.query == "abc=123"18    assert url.fragment == "anchor"19    assert (20        repr(url) == "URL('https://example.org:123/path/to/somewhere?abc=123#anchor')"21    )2223    new = url.copy_with(scheme="http")24    assert new == URL("http://example.org:123/path/to/somewhere?abc=123#anchor")25    assert new.scheme == "http"262728def test_url__params():29    url = URL("https://example.org:123/path/to/somewhere", params={"a": "123"})30    assert str(url) == "https://example.org:123/path/to/somewhere?a=123"3132    url = URL("https://example.org:123/path/to/somewhere?b=456", params={"a": "123"})33    assert str(url) == "https://example.org:123/path/to/somewhere?a=123"343536def test_url_set():37    urls = (38        URL("http://example.org:123/path/to/somewhere"),39        URL("http://example.org:123/path/to/somewhere/else"),40    )4142    url_set = set(urls)4344    assert all(url in urls for url in url_set)