Skip to content

Commit ed8858d

Browse files
committed
Skip hypothesis tests in environments without hypothesis installed
Fedora/EPEL RPM builds in Packit run %check without test-only deps on the buildroot. The collection step blew up trying to import hypothesis on rawhide and the rest of the matrix would have followed. pytest.importorskip is the standard idiom here: collects the module only if hypothesis is on the path, skips cleanly with a clear reason otherwise. GH Actions installs hypothesis via requirements.txt so the tests still run there; downstream packagers no longer need to care about it.
1 parent 72b9522 commit ed8858d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/test_hypothesis_properties.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@
4242

4343
import math
4444

45-
from hypothesis import given, settings, strategies as st
45+
import pytest
4646

47-
import bitmath
47+
# Downstream packagers (Fedora/EPEL RPM builds) run %check without
48+
# installing test-only dependencies. Skip the whole module when
49+
# hypothesis isn't on the path rather than failing collection.
50+
pytest.importorskip("hypothesis")
51+
52+
from hypothesis import given, settings, strategies as st # noqa: E402
53+
54+
import bitmath # noqa: E402
4855

4956

5057
# Bracketed to avoid values that Python's str() renders in scientific

0 commit comments

Comments
 (0)