Skip to content

Commit 8eb9cfc

Browse files
committed
Install and configure Hypothesis
1 parent 4b20d78 commit 8eb9cfc

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

INSTALL.rst.txt

+5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ Building NumPy requires the following installed software:
2626

2727
This is required for testing NumPy, but not for using it.
2828

29+
4) Hypothesis__ (optional) 5.3.0 or later
30+
31+
This is required for testing NumPy, but not for using it.
32+
2933
Python__ http://www.python.org
3034
pytest__ http://pytest.readthedocs.io
35+
Hypothesis__ https://hypothesis.readthedocs.io/en/latest/
3136

3237

3338
.. note::

doc/TESTS.rst.txt

+10
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,17 @@ deterministic by setting the random number seed before generating it. Use
360360
either Python's ``random.seed(some_number)`` or NumPy's
361361
``numpy.random.seed(some_number)``, depending on the source of random numbers.
362362

363+
Alternatively, you can use `Hypothesis`_ to generate arbitrary data.
364+
Hypothesis manages both Python's and Numpy's random seeds for you, and
365+
provides a very concise and powerful way to describe data (including
366+
``hypothesis.extra.numpy``, e.g. for a set of mutually-broadcastable shapes).
367+
368+
The advantages over random generation include tools to replay and share
369+
failures without requiring a fixed seed, reporting *minimal* examples for
370+
each failure, and better-than-naive-random techniques for triggering bugs.
371+
363372

364373
.. _nose: https://nose.readthedocs.io/en/latest/
365374
.. _pytest: https://pytest.readthedocs.io
366375
.. _parameterization: https://docs.pytest.org/en/latest/parametrize.html
376+
.. _Hypothesis: https://hypothesis.readthedocs.io/en/latest/

numpy/conftest.py

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
import os
55

6+
import hypothesis
67
import pytest
78
import numpy
89

@@ -12,6 +13,12 @@
1213
_old_fpu_mode = None
1314
_collect_results = {}
1415

16+
# See https://hypothesis.readthedocs.io/en/latest/settings.html
17+
hypothesis.settings.register_profile(
18+
name="numpy-profile", deadline=None, print_blob=True,
19+
)
20+
hypothesis.settings.load_profile("numpy-profile")
21+
1522

1623
def pytest_configure(config):
1724
config.addinivalue_line("markers",

test_requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cython==0.29.14
2+
hypothesis==5.3.0
23
pytest==5.3.5
34
pytz==2019.3
45
pytest-cov==2.8.1

0 commit comments

Comments
 (0)