Skip to content

Commit 1c1c4ab

Browse files
committed
Limit Hypothesis examples for unvectorized tests
1 parent 582955c commit 1c1c4ab

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from functools import lru_cache
22
from pathlib import Path
3+
import math
34
import warnings
45
import os
56

@@ -145,6 +146,7 @@ def pytest_collection_modifyitems(config, items):
145146

146147
disabled_exts = config.getoption("--disable-extension")
147148
disabled_dds = config.getoption("--disable-data-dependent-shapes")
149+
unvectorized_max_examples = math.ceil(math.log(config.getoption("--hypothesis-max-examples") or 50))
148150

149151
# 2. Iterate through items and apply markers accordingly
150152
# ------------------------------------------------------
@@ -191,6 +193,12 @@ def pytest_collection_modifyitems(config, items):
191193
reason=f"requires ARRAY_API_TESTS_VERSION=>{min_version}"
192194
)
193195
)
196+
# reduce max generated Hypothesis example for unvectorized tests
197+
if any(m.name == "unvectorized" for m in markers):
198+
# TODO: limit generated examples when settings already applied
199+
if not hasattr(item.obj, "_hypothesis_internal_settings_applied"):
200+
item.obj = settings(max_examples=unvectorized_max_examples)(item.obj)
201+
194202

195203
# 3. Warn on bad skipped/xfailed ids
196204
# ----------------------------------

0 commit comments

Comments
 (0)