]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Inline SERVER_SCOPE and remove typing_extensions requirement (#1773)
authorMichał Górny <mgorny@gentoo.org>
Mon, 26 Jul 2021 14:08:58 +0000 (16:08 +0200)
committerGitHub <noreply@github.com>
Mon, 26 Jul 2021 14:08:58 +0000 (15:08 +0100)
tests/conftest.py

index e2b980185e05d11228e1b10a1204229c2eed1c8c..1ed87a467a00833f8d32915601f1461142503300 100644 (file)
@@ -14,7 +14,6 @@ from cryptography.hazmat.primitives.serialization import (
     PrivateFormat,
     load_pem_private_key,
 )
-from typing_extensions import Literal
 from uvicorn.config import Config
 from uvicorn.main import Server
 
@@ -165,38 +164,35 @@ async def redirect_301(scope, receive, send):
     await send({"type": "http.response.body"})
 
 
-SERVER_SCOPE: Literal["session"] = "session"
-
-
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def cert_authority():
     return trustme.CA()
 
 
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def ca_cert_pem_file(cert_authority):
     with cert_authority.cert_pem.tempfile() as tmp:
         yield tmp
 
 
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def localhost_cert(cert_authority):
     return cert_authority.issue_cert("localhost")
 
 
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def cert_pem_file(localhost_cert):
     with localhost_cert.cert_chain_pems[0].tempfile() as tmp:
         yield tmp
 
 
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def cert_private_key_file(localhost_cert):
     with localhost_cert.private_key_pem.tempfile() as tmp:
         yield tmp
 
 
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def cert_encrypted_private_key_file(localhost_cert):
     # Deserialize the private key and then reserialize with a password
     private_key = load_pem_private_key(
@@ -272,14 +268,14 @@ def serve_in_thread(server: Server):
         thread.join()
 
 
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def server():
     config = Config(app=app, lifespan="off", loop="asyncio")
     server = TestServer(config=config)
     yield from serve_in_thread(server)
 
 
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
 def https_server(cert_pem_file, cert_private_key_file):
     config = Config(
         app=app,