Skip to content

Commit b3de838

Browse files
[PR #11367/cccbf4cd backport][3.13] Disable the blockbuster fixture when the module is not importable (#11402)
**This is a backport of PR #11367 as merged into master (cccbf4c).** Co-authored-by: Ben Beasley <[email protected]>
1 parent 3e3984e commit b3de838

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGES/11363.packaging

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The `blockbuster` test dependency is now optional; the corresponding test fixture is disabled when it is unavailable
2+
-- by :user:`musicinybrain`.

tests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
from uuid import uuid4
1313

1414
import pytest
15-
from blockbuster import blockbuster_ctx
15+
16+
try:
17+
from blockbuster import blockbuster_ctx
18+
19+
HAS_BLOCKBUSTER = True
20+
except ImportError: # For downstreams only # pragma: no cover
21+
HAS_BLOCKBUSTER = False
1622

1723
from aiohttp import payload
1824
from aiohttp.client_proto import ResponseHandler
@@ -45,7 +51,7 @@
4551
IS_LINUX = sys.platform.startswith("linux")
4652

4753

48-
@pytest.fixture(autouse=True)
54+
@pytest.fixture(autouse=HAS_BLOCKBUSTER)
4955
def blockbuster(request: pytest.FixtureRequest) -> Iterator[None]:
5056
# Allow selectively disabling blockbuster for specific tests
5157
# using the @pytest.mark.skip_blockbuster marker.

0 commit comments

Comments
 (0)