Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.3k
Get test suite back to 100% line coverage#406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,7 +30,14 @@ def test_proxies_parameter(proxies, expected_proxies): | ||
| def test_proxies_has_same_properties_as_dispatch(): | ||
| client = httpx.AsyncClient(proxies="http://127.0.0.1") | ||
| client = httpx.AsyncClient( | ||
| proxies="http://127.0.0.1", | ||
| verify="/path/to/verify", | ||
| cert="/path/to/cert", | ||
| trust_env=False, | ||
| timeout=30, | ||
| http_versions=["HTTP/1.1"], | ||
| ) | ||
| pool = client.dispatch | ||
| proxy = client.proxies["all"] | ||
| @@ -46,3 +53,66 @@ def test_proxies_has_same_properties_as_dispatch(): | ||
| "backend", | ||
| ]: | ||
| assert getattr(pool, prop) == getattr(proxy, prop) | ||
| PROXY_URL = "http://[::1]" | ||
| @pytest.mark.parametrize( | ||
| ["url", "proxies", "expected"], | ||
| [ | ||
| ("http://example.com", None, None), | ||
| ("http://example.com", {}, None), | ||
| ("http://example.com", {"https": PROXY_URL}, None), | ||
| ("http://example.com", {"http://example.net": PROXY_URL}, None), | ||
| ("http://example.com:443", {"http://example.com": PROXY_URL}, None), | ||
| ("http://example.com", {"all": PROXY_URL}, PROXY_URL), | ||
| ("http://example.com", {"http": PROXY_URL}, PROXY_URL), | ||
| ("http://example.com", {"all://example.com": PROXY_URL}, PROXY_URL), | ||
| ("http://example.com", {"all://example.com:80": PROXY_URL}, PROXY_URL), | ||
| ("http://example.com", {"http://example.com": PROXY_URL}, PROXY_URL), | ||
| ("http://example.com", {"http://example.com:80": PROXY_URL}, PROXY_URL), | ||
| ("http://example.com:8080", {"http://example.com:8080": PROXY_URL}, PROXY_URL), | ||
| ("http://example.com:8080", {"http://example.com": PROXY_URL}, None), | ||
| ( | ||
| "http://example.com", | ||
| { | ||
| "all": PROXY_URL + ":1", | ||
| "http": PROXY_URL + ":2", | ||
| "all://example.com": PROXY_URL + ":3", | ||
| "http://example.com": PROXY_URL + ":4", | ||
| }, | ||
| PROXY_URL + ":4", | ||
| ), | ||
| ( | ||
| "http://example.com", | ||
| { | ||
| "all": PROXY_URL + ":1", | ||
| "http": PROXY_URL + ":2", | ||
| "all://example.com": PROXY_URL + ":3", | ||
| }, | ||
| PROXY_URL + ":3", | ||
| ), | ||
| ( | ||
| "http://example.com", | ||
| {"all": PROXY_URL + ":1", "http": PROXY_URL + ":2"}, | ||
| PROXY_URL + ":2", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_dispatcher_for_request(url, proxies, expected): | ||
| client = httpx.AsyncClient(proxies=proxies) | ||
| request = httpx.AsyncRequest("GET", url) | ||
| dispatcher = client._dispatcher_for_request(request, client.proxies) | ||
| if expected is None: | ||
| assert isinstance(dispatcher, httpx.ConnectionPool) | ||
| assert dispatcher is client.dispatch | ||
| else: | ||
| assert isinstance(dispatcher, httpx.HTTPProxy) | ||
| assert dispatcher.proxy_url == expected | ||
yeraydiazdiaz marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def test_unsupported_proxy_scheme(): | ||
| with pytest.raises(ValueError): | ||
| httpx.AsyncClient(proxies="ftp://127.0.0.1") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -204,3 +204,11 @@ async def test_http2_settings_in_handshake(backend): | ||
| for setting_code, changed_setting in settings.changed_settings.items(): | ||
| assert isinstance(changed_setting, h2.settings.ChangedSetting) | ||
| assert changed_setting.new_value == expected_settings[setting_code] | ||
| async def test_http2_live_request(backend): | ||
| async with AsyncClient(backend=backend) as client: | ||
| resp = await client.get("https://nghttp2.org/httpbin/anything") | ||
| ||
| assert resp.status_code == 200 | ||
| assert resp.http_version == "HTTP/2" | ||
Uh oh!
There was an error while loading. Please reload this page.