summaryrefslogtreecommitdiff
path: root/numpy/conftest.py
diff options
context:
space:
mode:
authorZac-HD <zac.hatfield.dodds@gmail.com>2020-07-16 14:54:36 +1000
committerZac-HD <zac.hatfield.dodds@gmail.com>2020-07-23 14:23:40 +1000
commit3d74fab153420baa61dd8ccd284265393218f471 (patch)
treeb44ca132aa9d1319462935707bad10f865e3ba6f /numpy/conftest.py
parenta39e3021b9304fb5a76542d444b7fec2dcff1374 (diff)
downloadnumpy-3d74fab153420baa61dd8ccd284265393218f471.tar.gz
Configure hypothesis for np.test()
Diffstat (limited to 'numpy/conftest.py')
-rw-r--r--numpy/conftest.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/conftest.py b/numpy/conftest.py
index 20c8a449e..078b09566 100644
--- a/numpy/conftest.py
+++ b/numpy/conftest.py
@@ -2,6 +2,7 @@
Pytest configuration and fixtures for the Numpy test suite.
"""
import os
+import tempfile
import hypothesis
import pytest
@@ -13,11 +14,23 @@ from numpy.core._multiarray_tests import get_fpu_mode
_old_fpu_mode = None
_collect_results = {}
+# Use a known and persistent tmpdir for hypothesis' caches, which
+# can be automatically cleared by the OS or user.
+hypothesis.configuration.set_hypothesis_home_dir(
+ os.path.join(tempfile.gettempdir(), ".hypothesis")
+)
# See https://hypothesis.readthedocs.io/en/latest/settings.html
hypothesis.settings.register_profile(
name="numpy-profile", deadline=None, print_blob=True,
)
-hypothesis.settings.load_profile("numpy-profile")
+# We try loading the profile defined by np.test(), which disables the
+# database and forces determinism, and fall back to the profile defined
+# above if we're running pytest directly. The odd dance is required
+# because np.test() executes this file *after* its own setup code.
+try:
+ hypothesis.settings.load_profile("np.test() profile")
+except hypothesis.errors.InvalidArgument: # profile not found
+ hypothesis.settings.load_profile("numpy-profile")
def pytest_configure(config):