Fixed warnings in unit tests suite, caused by #1127 PR (#1137)

This commit is contained in:
cdeler 2020-08-06 15:41:11 +03:00 committed by GitHub
parent 7123b0f7ba
commit 0a38695063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -107,7 +107,7 @@ class BaseClient:
return new_proxies
else:
proxy = Proxy(url=proxies) if isinstance(proxies, (str, URL)) else proxies
return {"all": proxy}
return {"all://": proxy}
@property
def timeout(self) -> Timeout:
@ -1034,6 +1034,7 @@ class AsyncClient(BaseClient):
app=app,
trust_env=trust_env,
)
self._proxies: typing.Dict[
URLPattern, typing.Optional[httpcore.AsyncHTTPTransport]
] = {

View File

@ -312,7 +312,9 @@ def get_environment_proxies() -> typing.Dict[str, typing.Optional[str]]:
for scheme in ("http", "https", "all"):
if proxy_info.get(scheme):
hostname = proxy_info[scheme]
mounts[scheme] = hostname if "://" in hostname else f"http://{hostname}"
mounts[f"{scheme}://"] = (
hostname if "://" in hostname else f"http://{hostname}"
)
no_proxy_hosts = [host.strip() for host in proxy_info.get("no", "").split(",")]
for hostname in no_proxy_hosts:

View File

@ -192,12 +192,12 @@ async def test_elapsed_timer():
["environment", "proxies"],
[
({}, {}),
({"HTTP_PROXY": "http://127.0.0.1"}, {"http": "http://127.0.0.1"}),
({"HTTP_PROXY": "http://127.0.0.1"}, {"http://": "http://127.0.0.1"}),
(
{"https_proxy": "http://127.0.0.1", "HTTP_PROXY": "https://127.0.0.1"},
{"https": "http://127.0.0.1", "http": "https://127.0.0.1"},
{"https://": "http://127.0.0.1", "http://": "https://127.0.0.1"},
),
({"all_proxy": "http://127.0.0.1"}, {"all": "http://127.0.0.1"}),
({"all_proxy": "http://127.0.0.1"}, {"all://": "http://127.0.0.1"}),
({"TRAVIS_APT_PROXY": "http://127.0.0.1"}, {}),
],
)
@ -247,9 +247,7 @@ def test_not_same_origin():
("all://example.com", "https://example.com", True,),
("http://", "http://example.com", True,),
("http://", "https://example.com", False,),
("http", "http://example.com", True,),
("http", "https://example.com", False,),
("all", "https://example.com:123", True,),
("all://", "https://example.com:123", True,),
("", "https://example.com:123", True,),
],
)