From cccbf4cd3390729afe6ebe4c1078c2c979016503 Mon Sep 17 00:00:00 2001 From: Ben Beasley Date: Sat, 9 Aug 2025 17:23:29 -0400 Subject: [PATCH] Disable the blockbuster fixture when the module is not importable (#11367) --- CHANGES/11363.packaging | 2 ++ tests/conftest.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 CHANGES/11363.packaging diff --git a/CHANGES/11363.packaging b/CHANGES/11363.packaging new file mode 100644 index 00000000000..65d54bf48c0 --- /dev/null +++ b/CHANGES/11363.packaging @@ -0,0 +1,2 @@ +The `blockbuster` test dependency is now optional; the corresponding test fixture is disabled when it is unavailable +-- by :user:`musicinybrain`. diff --git a/tests/conftest.py b/tests/conftest.py index 24c023738da..41ed907ea70 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,7 +12,13 @@ from uuid import uuid4 import pytest -from blockbuster import blockbuster_ctx + +try: + from blockbuster import blockbuster_ctx + + HAS_BLOCKBUSTER = True +except ImportError: # For downstreams only # pragma: no cover + HAS_BLOCKBUSTER = False from aiohttp import payload from aiohttp.client_proto import ResponseHandler @@ -46,7 +52,7 @@ IS_LINUX = sys.platform.startswith("linux") -@pytest.fixture(autouse=True) +@pytest.fixture(autouse=HAS_BLOCKBUSTER) def blockbuster(request: pytest.FixtureRequest) -> Iterator[None]: # Allow selectively disabling blockbuster for specific tests # using the @pytest.mark.skip_blockbuster marker.