@@ -795,6 +795,44 @@ Tests that we have ``parametrized`` are now accessible via the test name, for ex
795795 test_cool_feature.py::test_series[int8 ] PASSED
796796
797797
798+ Using ``hypothesis``
799+ ~~~~~~~~~~~~~~~~~~~~
800+
801+ Hypothesis is a library for property-based testing. Instead of explicitly
802+ parametrizing a test, you can describe *all* valid inputs and let Hypothesis
803+ try to find a failing input. Even better, no matter how many random examples
804+ it tries, Hypothesis always reports a single minimal counterexample to your
805+ assertions - often an example that you would never have thought to test.
806+
807+ See `Getting Started with Hypothesis <https://hypothesis.works/articles/getting-started-with-hypothesis/>`_
808+ for more of an introduction, then `refer to the Hypothesis documentation
809+ for details <https://hypothesis.readthedocs.io/en/latest/index.html>`_.
810+
811+ .. code-block:: python
812+
813+ import json
814+ from hypothesis import given, strategies as st
815+
816+ any_json_value = st.deferred(lambda: st.one_of(
817+ st.none(), st.booleans(), st.floats(allow_nan=False), st.text(),
818+ st.lists(any_json_value), st.dictionaries(st.text(), any_json_value)
819+ ))
820+
821+ @given(value=any_json_value)
822+ def test_json_roundtrip(value):
823+ result = json.loads(json.dumps(value))
824+ assert value == result
825+
826+ This test shows off several useful features of Hypothesis, as well as
827+ demonstrating a good use-case: checking properties that should hold over
828+ a large or complicated domain of inputs.
829+
830+ To keep the Pandas test suite running quickly, parametrized tests are
831+ preferred if the inputs or logic are simple, with Hypothesis tests reserved
832+ for cases with complex logic or where there are too many combinations of
833+ options or subtle interactions to test (or think of!) all of them.
834+
835+
798836Running the test suite
799837----------------------
800838
0 commit comments