Skip to content

Commit 2f611af

Browse files
committed
run all conjecture tests in cover jobs
1 parent e182f69 commit 2f611af

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

hypothesis-python/tests/conjecture/test_alt_backend.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010

1111
import math
1212
import sys
13-
from collections.abc import Sequence
1413
from contextlib import contextmanager
1514
from random import Random
16-
from typing import Optional
15+
from typing import Optional, Sequence
1716

1817
import pytest
1918

@@ -454,17 +453,15 @@ def observe_information_messages(self, *, lifetime):
454453

455454

456455
def test_custom_observations_from_backend():
457-
with (
458-
temp_register_backend("observable", ObservableProvider),
459-
capture_observations() as ls,
460-
):
456+
with temp_register_backend("observable", ObservableProvider):
461457

462458
@given(st.none())
463459
@settings(backend="observable", database=None)
464460
def test_function(_):
465461
pass
466462

467-
test_function()
463+
with capture_observations() as ls:
464+
test_function()
468465

469466
assert len(ls) >= 3
470467
cases = [t["metadata"]["backend"] for t in ls if t["type"] == "test_case"]

hypothesis-python/tests/conjecture/test_utils.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from collections import Counter
1212
from fractions import Fraction
1313

14-
import numpy as np
1514
import pytest
1615

1716
from hypothesis import (
@@ -30,6 +29,11 @@
3029
from hypothesis.internal.coverage import IN_COVERAGE_TESTS
3130
from hypothesis.internal.intervalsets import IntervalSet
3231

32+
try:
33+
import numpy as np
34+
except ImportError:
35+
np = None
36+
3337

3438
def test_coin_biased_towards_truth():
3539
p = 1 - 1.0 / 500
@@ -222,11 +226,13 @@ def test_combine_labels_is_distinct():
222226
assert cu.combine_labels(x, y) not in (x, y)
223227

224228

229+
@pytest.mark.skipif(np is None, reason="requires Numpy")
225230
def test_invalid_numpy_sample():
226231
with pytest.raises(InvalidArgument):
227232
cu.check_sample(np.array([[1, 1], [1, 1]]), "array")
228233

229234

235+
@pytest.mark.skipif(np is None, reason="requires Numpy")
230236
def test_valid_numpy_sample():
231237
cu.check_sample(np.array([1, 2, 3]), "array")
232238

hypothesis-python/tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ setenv=
2020
commands =
2121
full: bash scripts/basic-test.sh
2222
brief: python -bb -X dev -m pytest -n auto tests/cover/test_testdecorators.py {posargs}
23-
cover: python -bb -X dev -m pytest -n auto tests/cover/ tests/pytest/ tests/conjecture/test_inquisitor.py {posargs}
23+
cover: python -bb -X dev -m pytest -n auto tests/cover/ tests/pytest/ tests/conjecture/ {posargs}
24+
conjecture: python -bb -X dev -m pytest -n auto tests/conjecture/ {posargs}
2425
nocover: python -bb -X dev -m pytest -n auto tests/nocover/ {posargs}
2526
niche: bash scripts/other-tests.sh
2627
custom: python -bb -X dev -m pytest {posargs}

0 commit comments

Comments
 (0)