From e2815fbc88e47c7037af8b0114e33ccf506e8edc Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 18 Sep 2024 22:31:36 +0100 Subject: [PATCH] move httbin_ssl_context fixture into the one place it's used --- tests/integration/conftest.py | 16 ---------------- tests/integration/test_aiohttp.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 16 deletions(-) delete mode 100644 tests/integration/conftest.py diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py deleted file mode 100644 index 05908e5..0000000 --- a/tests/integration/conftest.py +++ /dev/null @@ -1,16 +0,0 @@ -import os -import ssl - -import pytest - - -@pytest.fixture -def httpbin_ssl_context(): - ssl_ca_location = os.environ["REQUESTS_CA_BUNDLE"] - ssl_cert_location = os.environ["REQUESTS_CA_BUNDLE"].replace("cacert.pem", "cert.pem") - ssl_key_location = os.environ["REQUESTS_CA_BUNDLE"].replace("cacert.pem", "key.pem") - - ssl_context = ssl.create_default_context(cafile=ssl_ca_location) - ssl_context.load_cert_chain(ssl_cert_location, ssl_key_location) - - return ssl_context diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py index 7bf5d77..4bcf898 100644 --- a/tests/integration/test_aiohttp.py +++ b/tests/integration/test_aiohttp.py @@ -1,4 +1,6 @@ import logging +import os +import ssl import urllib.parse import pytest @@ -12,6 +14,18 @@ aiohttp = pytest.importorskip("aiohttp") from .aiohttp_utils import aiohttp_app, aiohttp_request # noqa: E402 +@pytest.fixture +def httpbin_ssl_context(): + ssl_ca_location = os.environ["REQUESTS_CA_BUNDLE"] + ssl_cert_location = os.environ["REQUESTS_CA_BUNDLE"].replace("cacert.pem", "cert.pem") + ssl_key_location = os.environ["REQUESTS_CA_BUNDLE"].replace("cacert.pem", "key.pem") + + ssl_context = ssl.create_default_context(cafile=ssl_ca_location) + ssl_context.load_cert_chain(ssl_cert_location, ssl_key_location) + + return ssl_context + + def run_in_loop(fn): async def wrapper(): return await fn(asyncio.get_running_loop())