]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add exported members test (#1179)
authorJosep Cugat <jcugat@gmail.com>
Sat, 15 Aug 2020 10:24:26 +0000 (12:24 +0200)
committerGitHub <noreply@github.com>
Sat, 15 Aug 2020 10:24:26 +0000 (12:24 +0200)
Taken from https://github.com/encode/httpcore/pull/156
Added as a followup of https://github.com/encode/httpx/pull/1177#issuecomment-674252582

httpx/__init__.py
tests/test_exported_members.py [new file with mode: 0644]

index 5f503cd028dcd6261b7b6a3867896b1c4f1de53b..38024394667bf8da11880d07d0562b5b95a47861 100644 (file)
@@ -45,73 +45,71 @@ __all__ = [
     "__description__",
     "__title__",
     "__version__",
-    "delete",
-    "get",
-    "head",
-    "options",
-    "patch",
-    "post",
-    "patch",
-    "put",
-    "request",
-    "stream",
-    "codes",
     "ASGITransport",
     "AsyncClient",
     "Auth",
     "BasicAuth",
     "Client",
-    "DigestAuth",
-    "Limits",
-    "PoolLimits",
-    "Proxy",
-    "Timeout",
-    "create_ssl_context",
     "CloseError",
+    "codes",
     "ConnectError",
     "ConnectTimeout",
     "CookieConflict",
+    "Cookies",
+    "create_ssl_context",
     "DecodingError",
+    "delete",
+    "DigestAuth",
+    "get",
+    "head",
+    "Headers",
     "HTTPError",
     "HTTPStatusError",
     "InvalidURL",
-    "UnsupportedProtocol",
+    "Limits",
     "LocalProtocolError",
-    "RemoteProtocolError",
     "NetworkError",
     "NotRedirectResponse",
+    "options",
+    "patch",
+    "PoolLimits",
     "PoolTimeout",
+    "post",
     "ProtocolError",
+    "Proxy",
+    "ProxyError",
+    "put",
+    "QueryParams",
     "ReadError",
     "ReadTimeout",
-    "RequestError",
+    "RemoteProtocolError",
+    "request",
+    "Request",
     "RequestBodyUnavailable",
+    "RequestError",
+    "RequestNotRead",
+    "Response",
     "ResponseClosed",
     "ResponseNotRead",
-    "RequestNotRead",
     "StatusCode",
+    "stream",
     "StreamConsumed",
     "StreamError",
-    "ProxyError",
+    "Timeout",
     "TimeoutException",
     "TooManyRedirects",
     "TransportError",
-    "WriteError",
-    "WriteTimeout",
+    "UnsupportedProtocol",
     "URL",
-    "URLLib3Transport",
     "URLLib3ProxyTransport",
-    "Cookies",
-    "Headers",
-    "QueryParams",
-    "Request",
-    "Response",
-    "DigestAuth",
+    "URLLib3Transport",
+    "WriteError",
+    "WriteTimeout",
     "WSGITransport",
 ]
 
 
-_locals = locals()
-for _name in __all__:
-    if not _name.startswith("__"):
-        setattr(_locals[_name], "__module__", "httpx")  # noqa
+__locals = locals()
+for __name in __all__:
+    if not __name.startswith("__"):
+        setattr(__locals[__name], "__module__", "httpx")  # noqa
diff --git a/tests/test_exported_members.py b/tests/test_exported_members.py
new file mode 100644 (file)
index 0000000..ca4a9ed
--- /dev/null
@@ -0,0 +1,14 @@
+import httpx
+from httpx import __all__ as exported_members
+
+
+def test_all_imports_are_exported() -> None:
+    included_private_members = ["__description__", "__title__", "__version__"]
+    assert exported_members == sorted(
+        (
+            member
+            for member in vars(httpx).keys()
+            if not member.startswith("_") or member in included_private_members
+        ),
+        key=str.casefold,
+    )