Ejemplo n.º 1
0
def test_proxies_parameter(proxies, expected_proxies):
    client = httpx.Client(proxies=proxies)

    for proxy_key, url in expected_proxies:
        pattern = URLPattern(proxy_key)
        assert pattern in client._mounts
        proxy = client._mounts[pattern]
        assert isinstance(proxy, httpcore.SyncHTTPProxy)
        assert proxy.proxy_origin == url_to_origin(url)

    assert len(expected_proxies) == len(client._mounts)
Ejemplo n.º 2
0
def test_pattern_priority():
    matchers = [
        URLPattern("all://"),
        URLPattern("http://"),
        URLPattern("http://example.com"),
        URLPattern("http://example.com:123"),
    ]
    random.shuffle(matchers)
    assert sorted(matchers) == [
        URLPattern("http://example.com:123"),
        URLPattern("http://example.com"),
        URLPattern("http://"),
        URLPattern("all://"),
    ]
Ejemplo n.º 3
0
def test_url_matches(pattern, url, expected):
    pattern = URLPattern(pattern)
    assert pattern.matches(httpx.URL(url)) == expected