Skip to content

Commit

Permalink
run all conjecture tests in cover jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Oct 5, 2024
1 parent e182f69 commit 2f611af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
11 changes: 4 additions & 7 deletions hypothesis-python/tests/conjecture/test_alt_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

import math
import sys
from collections.abc import Sequence
from contextlib import contextmanager
from random import Random
from typing import Optional
from typing import Optional, Sequence

import pytest

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


def test_custom_observations_from_backend():
with (
temp_register_backend("observable", ObservableProvider),
capture_observations() as ls,
):
with temp_register_backend("observable", ObservableProvider):

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

test_function()
with capture_observations() as ls:
test_function()

assert len(ls) >= 3
cases = [t["metadata"]["backend"] for t in ls if t["type"] == "test_case"]
Expand Down
8 changes: 7 additions & 1 deletion hypothesis-python/tests/conjecture/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from collections import Counter
from fractions import Fraction

import numpy as np
import pytest

from hypothesis import (
Expand All @@ -30,6 +29,11 @@
from hypothesis.internal.coverage import IN_COVERAGE_TESTS
from hypothesis.internal.intervalsets import IntervalSet

try:
import numpy as np
except ImportError:
np = None


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


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


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

Expand Down
3 changes: 2 additions & 1 deletion hypothesis-python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ setenv=
commands =
full: bash scripts/basic-test.sh
brief: python -bb -X dev -m pytest -n auto tests/cover/test_testdecorators.py {posargs}
cover: python -bb -X dev -m pytest -n auto tests/cover/ tests/pytest/ tests/conjecture/test_inquisitor.py {posargs}
cover: python -bb -X dev -m pytest -n auto tests/cover/ tests/pytest/ tests/conjecture/ {posargs}
conjecture: python -bb -X dev -m pytest -n auto tests/conjecture/ {posargs}
nocover: python -bb -X dev -m pytest -n auto tests/nocover/ {posargs}
niche: bash scripts/other-tests.sh
custom: python -bb -X dev -m pytest {posargs}
Expand Down

0 comments on commit 2f611af

Please sign in to comment.