]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Fixed warnings in unit tests suite, caused by #1127 PR (#1137)
authorcdeler <serj.krotov@gmail.com>
Thu, 6 Aug 2020 12:41:11 +0000 (15:41 +0300)
committerGitHub <noreply@github.com>
Thu, 6 Aug 2020 12:41:11 +0000 (13:41 +0100)
httpx/_client.py
httpx/_utils.py
tests/test_utils.py

index 1829b9575bc958b8bdd4dc1700d0e82d345d921a..7f4d257e748531ce647c401cbb2a6f5cbba96409 100644 (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]
         ] = {
index 67f1c9105fed5f0ac41c84d76a49c97ac3757185..476407e7d75ae06f3439728f64eb9e1642c225ac 100644 (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:
index d564ceb75a26dd5e2914fd81be86749c7f8aebf4..461e4b962a3bac6627cd8f535b39ddfb6c083d3b 100644 (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,),
     ],
 )