Skip to content

Commit 2e54d6e

Browse files
Zac-HDtm9k1
authored andcommitted
TST: tweak Hypothesis configuration and idioms (pandas-dev#23441)
* Adjust Hypothesis timeout settings * Define strategy as function, not method
1 parent 457176f commit 2e54d6e

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

pandas/conftest.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
hypothesis.settings.register_profile(
1515
"ci",
1616
# Hypothesis timing checks are tuned for scalars by default, so we bump
17-
# them from 200ms to 5 secs per test case as the global default. If this
17+
# them from 200ms to 500ms per test case as the global default. If this
1818
# is too short for a specific test, (a) try to make it faster, and (b)
19-
# if it really is slow add `@settings(timeout=...)` with a working value.
20-
timeout=5000,
19+
# if it really is slow add `@settings(deadline=...)` with a working value,
20+
# or `deadline=None` to entirely disable timeouts for that test.
21+
deadline=500,
22+
timeout=hypothesis.unlimited,
2123
suppress_health_check=(hypothesis.HealthCheck.too_slow,)
2224
)
2325
hypothesis.settings.load_profile("ci")

pandas/tests/frame/test_apply.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,20 @@ def zip_frames(frames, axis=1):
823823
return pd.DataFrame(zipped)
824824

825825

826+
@composite
827+
def indices(draw, max_length=5):
828+
date = draw(
829+
dates(
830+
min_value=Timestamp.min.ceil("D").to_pydatetime().date(),
831+
max_value=Timestamp.max.floor("D").to_pydatetime().date(),
832+
).map(Timestamp)
833+
)
834+
periods = draw(integers(0, max_length))
835+
freq = draw(sampled_from(list("BDHTS")))
836+
dr = date_range(date, periods=periods, freq=freq)
837+
return pd.DatetimeIndex(list(dr))
838+
839+
826840
class TestDataFrameAggregate():
827841

828842
def test_agg_transform(self, axis, float_frame):
@@ -1142,20 +1156,7 @@ def test_agg_cython_table_raises(self, df, func, expected, axis):
11421156
with pytest.raises(expected):
11431157
df.agg(func, axis=axis)
11441158

1145-
@composite
1146-
def indices(draw, max_length=5):
1147-
date = draw(
1148-
dates(
1149-
min_value=Timestamp.min.ceil("D").to_pydatetime().date(),
1150-
max_value=Timestamp.max.floor("D").to_pydatetime().date(),
1151-
).map(Timestamp)
1152-
)
1153-
periods = draw(integers(0, max_length))
1154-
freq = draw(sampled_from(list("BDHTS")))
1155-
dr = date_range(date, periods=periods, freq=freq)
1156-
return pd.DatetimeIndex(list(dr))
1157-
1158-
@given(index=indices(5), num_columns=integers(0, 5))
1159+
@given(index=indices(max_length=5), num_columns=integers(0, 5))
11591160
def test_frequency_is_original(self, index, num_columns):
11601161
# GH 22150
11611162
original = index.copy()

0 commit comments

Comments
 (0)