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)
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://"), ]
def test_url_matches(pattern, url, expected): pattern = URLPattern(pattern) assert pattern.matches(httpx.URL(url)) == expected