@@ -820,6 +820,44 @@ Tests that we have ``parametrized`` are now accessible via the test name, for ex
820820 test_cool_feature.py::test_series[int8 ] PASSED
821821
822822
823+ Using ``hypothesis``
824+ ~~~~~~~~~~~~~~~~~~~~
825+
826+ Hypothesis is a library for property-based testing. Instead of explicitly
827+ parametrizing a test, you can describe *all* valid inputs and let Hypothesis
828+ try to find a failing input. Even better, no matter how many random examples
829+ it tries, Hypothesis always reports a single minimal counterexample to your
830+ assertions - often an example that you would never have thought to test.
831+
832+ See `Getting Started with Hypothesis <https://hypothesis.works/articles/getting-started-with-hypothesis/>`_
833+ for more of an introduction, then `refer to the Hypothesis documentation
834+ for details <https://hypothesis.readthedocs.io/en/latest/index.html>`_.
835+
836+ .. code-block:: python
837+
838+ import json
839+ from hypothesis import given, strategies as st
840+
841+ any_json_value = st.deferred(lambda: st.one_of(
842+ st.none(), st.booleans(), st.floats(allow_nan=False), st.text(),
843+ st.lists(any_json_value), st.dictionaries(st.text(), any_json_value)
844+ ))
845+
846+ @given(value=any_json_value)
847+ def test_json_roundtrip(value):
848+ result = json.loads(json.dumps(value))
849+ assert value == result
850+
851+ This test shows off several useful features of Hypothesis, as well as
852+ demonstrating a good use-case: checking properties that should hold over
853+ a large or complicated domain of inputs.
854+
855+ To keep the Pandas test suite running quickly, parametrized tests are
856+ preferred if the inputs or logic are simple, with Hypothesis tests reserved
857+ for cases with complex logic or where there are too many combinations of
858+ options or subtle interactions to test (or think of!) all of them.
859+
860+
823861Running the test suite
824862----------------------
825863
0 commit comments