Skip to content

Commit 30f5cea

Browse files
authored
Merge pull request #4456 from tybug/next
Speed up slow tests, increase db listener test retries
2 parents 6bd1831 + eeb1668 commit 30f5cea

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

hypothesis-python/tests/cover/test_lookup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ def test_resolves_builtin_types(t):
11491149

11501150
@pytest.mark.parametrize("t", BUILTIN_TYPES, ids=lambda t: t.__name__)
11511151
@given(data=st.data())
1152+
@settings(max_examples=20)
11521153
def test_resolves_forwardrefs_to_builtin_types(t, data):
11531154
s = st.from_type(typing.ForwardRef(t.__name__))
11541155
v = data.draw(s)

hypothesis-python/tests/nocover/test_characters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def _enc(cdc):
5757
reason="takes 2000s; large & slow symbolic strings",
5858
)
5959
@given(data=st.data(), codec=st.sampled_from(lots_of_encodings))
60+
@settings(max_examples=20)
6061
def test_can_constrain_characters_to_codec(data, codec):
61-
s = data.draw(st.text(st.characters(codec=codec), min_size=100))
62+
s = data.draw(st.text(st.characters(codec=codec), min_size=50))
6263
s.encode(codec)

hypothesis-python/tests/nocover/test_health_checks.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import pytest
1414
from pytest import raises
1515

16-
from hypothesis import HealthCheck, Phase, given, settings, strategies as st
16+
from hypothesis import HealthCheck, Phase, given, seed, settings, strategies as st
1717
from hypothesis.errors import FailedHealthCheck
1818
from hypothesis.internal.conjecture.data import ConjectureData
1919
from hypothesis.internal.conjecture.engine import BUFFER_SIZE
@@ -107,21 +107,22 @@ def test(n):
107107
test()
108108

109109

110-
def test_does_not_trigger_health_check_when_most_examples_are_small(monkeypatch):
111-
with deterministic_PRNG():
112-
for _ in range(100):
113-
# Setting max_examples=11 ensures we have enough examples for the
114-
# health checks to finish running, but cuts the generation short
115-
# after that point to allow this test to run in reasonable time.
116-
@settings(database=None, max_examples=11, phases=[Phase.generate])
117-
@given(
118-
st.integers(0, 100).flatmap(
119-
lambda n: st.binary(
120-
min_size=min(n * 100, BUFFER_SIZE), max_size=n * 100
121-
)
110+
def test_does_not_trigger_health_check_when_most_examples_are_small():
111+
for i in range(10):
112+
113+
@seed(i)
114+
# Setting max_examples=11 ensures we have enough examples for the
115+
# health checks to finish running, but cuts the generation short
116+
# after that point to allow this test to run in reasonable time.
117+
@settings(database=None, max_examples=11, phases=[Phase.generate])
118+
@given(
119+
st.integers(0, 100).flatmap(
120+
lambda n: st.binary(
121+
min_size=min(n * 100, BUFFER_SIZE), max_size=n * 100
122122
)
123123
)
124-
def test(b):
125-
pass
124+
)
125+
def test(b):
126+
pass
126127

127-
test()
128+
test()

hypothesis-python/tests/watchdog/test_database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_database_listener_directory():
4545
# seen flaky on test-win; we get *three* of the same save events in the first
4646
# assertion, which...is baffling, and possibly a genuine bug (most likely in
4747
# watchdog).
48-
@flaky(max_runs=2, min_passes=1)
48+
@flaky(max_runs=5, min_passes=1)
4949
def test_database_listener_multiplexed(tmp_path):
5050
db = MultiplexedDatabase(
5151
InMemoryExampleDatabase(), DirectoryBasedExampleDatabase(tmp_path)
@@ -96,7 +96,7 @@ def wait_for(condition, *, timeout=1, interval=0.01):
9696

9797

9898
# seen flaky on check-coverage (timeout in first wait_for)
99-
@flaky(max_runs=2, min_passes=1)
99+
@flaky(max_runs=5, min_passes=1)
100100
def test_database_listener_directory_explicit(tmp_path):
101101
db = DirectoryBasedExampleDatabase(tmp_path)
102102
events = []
@@ -167,7 +167,7 @@ def listener(event):
167167

168168

169169
# seen flaky on windows CI (timeout in wait_for)
170-
@flaky(max_runs=2, min_passes=1)
170+
@flaky(max_runs=5, min_passes=1)
171171
def test_database_listener_directory_move(tmp_path):
172172
db = DirectoryBasedExampleDatabase(tmp_path)
173173
events = []

0 commit comments

Comments
 (0)