summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL.rst.txt5
-rw-r--r--doc/TESTS.rst.txt10
-rw-r--r--numpy/conftest.py7
-rw-r--r--test_requirements.txt1
4 files changed, 23 insertions, 0 deletions
diff --git a/INSTALL.rst.txt b/INSTALL.rst.txt
index 30f58fa6d..2b9226751 100644
--- a/INSTALL.rst.txt
+++ b/INSTALL.rst.txt
@@ -26,8 +26,13 @@ Building NumPy requires the following installed software:
This is required for testing NumPy, but not for using it.
+4) Hypothesis__ (optional) 5.3.0 or later
+
+ This is required for testing NumPy, but not for using it.
+
Python__ http://www.python.org
pytest__ http://pytest.readthedocs.io
+Hypothesis__ https://hypothesis.readthedocs.io/en/latest/
.. note::
diff --git a/doc/TESTS.rst.txt b/doc/TESTS.rst.txt
index 9023c7100..007840b39 100644
--- a/doc/TESTS.rst.txt
+++ b/doc/TESTS.rst.txt
@@ -360,7 +360,17 @@ deterministic by setting the random number seed before generating it. Use
either Python's ``random.seed(some_number)`` or NumPy's
``numpy.random.seed(some_number)``, depending on the source of random numbers.
+Alternatively, you can use `Hypothesis`_ to generate arbitrary data.
+Hypothesis manages both Python's and Numpy's random seeds for you, and
+provides a very concise and powerful way to describe data (including
+``hypothesis.extra.numpy``, e.g. for a set of mutually-broadcastable shapes).
+
+The advantages over random generation include tools to replay and share
+failures without requiring a fixed seed, reporting *minimal* examples for
+each failure, and better-than-naive-random techniques for triggering bugs.
+
.. _nose: https://nose.readthedocs.io/en/latest/
.. _pytest: https://pytest.readthedocs.io
.. _parameterization: https://docs.pytest.org/en/latest/parametrize.html
+.. _Hypothesis: https://hypothesis.readthedocs.io/en/latest/
diff --git a/numpy/conftest.py b/numpy/conftest.py
index a843f725f..1d3e0349f 100644
--- a/numpy/conftest.py
+++ b/numpy/conftest.py
@@ -3,6 +3,7 @@ Pytest configuration and fixtures for the Numpy test suite.
"""
import os
+import hypothesis
import pytest
import numpy
@@ -12,6 +13,12 @@ from numpy.core._multiarray_tests import get_fpu_mode
_old_fpu_mode = None
_collect_results = {}
+# 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")
+
def pytest_configure(config):
config.addinivalue_line("markers",
diff --git a/test_requirements.txt b/test_requirements.txt
index a4b0fcc30..f4286d85d 100644
--- a/test_requirements.txt
+++ b/test_requirements.txt
@@ -1,4 +1,5 @@
cython==0.29.14
+hypothesis==5.3.0
pytest==5.3.5
pytz==2019.3
pytest-cov==2.8.1