Skip to content

Commit 4eef5f6

Browse files
authored
TST: Speed up hypothesis and slow tests (#62028)
1 parent 364ca58 commit 4eef5f6

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

pandas/conftest.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,19 @@ def pytest_collection_modifyitems(items, config) -> None:
176176
ignore_doctest_warning(item, path, message)
177177

178178

179-
hypothesis_health_checks = [
180-
hypothesis.HealthCheck.too_slow,
181-
hypothesis.HealthCheck.differing_executors,
182-
]
183-
184-
# Hypothesis
179+
# Similar to "ci" config in
180+
# https://hypothesis.readthedocs.io/en/latest/reference/api.html#built-in-profiles
185181
hypothesis.settings.register_profile(
186-
"ci",
187-
# Hypothesis timing checks are tuned for scalars by default, so we bump
188-
# them from 200ms to 500ms per test case as the global default. If this
189-
# is too short for a specific test, (a) try to make it faster, and (b)
190-
# if it really is slow add `@settings(deadline=...)` with a working value,
191-
# or `deadline=None` to entirely disable timeouts for that test.
192-
# 2022-02-09: Changed deadline from 500 -> None. Deadline leads to
193-
# non-actionable, flaky CI failures (# GH 24641, 44969, 45118, 44969)
182+
"pandas_ci",
183+
database=None,
194184
deadline=None,
195-
suppress_health_check=tuple(hypothesis_health_checks),
185+
max_examples=15,
186+
suppress_health_check=(
187+
hypothesis.HealthCheck.too_slow,
188+
hypothesis.HealthCheck.differing_executors,
189+
),
196190
)
197-
hypothesis.settings.load_profile("ci")
191+
hypothesis.settings.load_profile("pandas_ci")
198192

199193
# Registering these strategies makes them globally available via st.from_type,
200194
# which is use for offsets in tests/tseries/offsets/test_offsets_properties.py

pandas/tests/frame/test_stack_unstack.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,7 @@ def test_unstack_unobserved_keys(self, future_stack):
22272227
tm.assert_frame_equal(recons, df)
22282228

22292229
@pytest.mark.slow
2230-
def test_unstack_number_of_levels_larger_than_int32(
2230+
def test_unstack_number_of_levels_larger_than_int32_warns(
22312231
self, performance_warning, monkeypatch
22322232
):
22332233
# GH#20601
@@ -2239,6 +2239,9 @@ def __init__(self, *args, **kwargs) -> None:
22392239
super().__init__(*args, **kwargs)
22402240
raise Exception("Don't compute final result.")
22412241

2242+
def _make_selectors(self) -> None:
2243+
pass
2244+
22422245
with monkeypatch.context() as m:
22432246
m.setattr(reshape_lib, "_Unstacker", MockUnstacker)
22442247
df = DataFrame(

pandas/tests/reshape/test_pivot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ def test_pivot_string_func_vs_func(self, f, f_numpy, data):
21352135
tm.assert_frame_equal(result, expected)
21362136

21372137
@pytest.mark.slow
2138-
def test_pivot_number_of_levels_larger_than_int32(
2138+
def test_pivot_number_of_levels_larger_than_int32_warns(
21392139
self, performance_warning, monkeypatch
21402140
):
21412141
# GH 20601
@@ -2146,6 +2146,9 @@ def __init__(self, *args, **kwargs) -> None:
21462146
super().__init__(*args, **kwargs)
21472147
raise Exception("Don't compute final result.")
21482148

2149+
def _make_selectors(self) -> None:
2150+
pass
2151+
21492152
with monkeypatch.context() as m:
21502153
m.setattr(reshape_lib, "_Unstacker", MockUnstacker)
21512154
df = DataFrame(

0 commit comments

Comments
 (0)