Using the hypothesis
library for unit testing, I am wondering how I can reproduce a falsifying example pd.DataFrame
?
The output looks like this:
Falsifying example: test_data_frame_data(
data= sec_1 sec_2 sec_3
2020-01-01 00:00:00.000001 0.0 -0.0 0.0
2020-01-01 00:00:00.000000 0.0 -0.0 0.0
2020-01-01 00:00:00.000257 0.0 -0.0 0.0
2020-01-01 00:00:00.000258 0.0 -0.0 0.0
2020-01-01 00:00:00.000261 0.0 -0.0 0.0
... ... ... ...
2020-01-01 00:00:01.526858 0.0 -0.0 0.0
2020-01-01 01:00:01.065796 0.0 -0.0 0.0
2020-01-01 01:00:01.065797 0.0 -0.0 0.0
2020-01-01 01:01:01.065795 0.0 -0.0 0.0
2020-01-01 00:01:01.000020 0.0 -0.0 0.0
[300 rows x 3 columns],
)
Hypothesis
didn't print a seed
or a hint to @reproduce_failure
.
I simply would like to use the falsifying example to debug my code.
I got a hint on the hypothesis GitHub issues page (https://github.com/HypothesisWorks/hypothesis/issues/2584). Credits to @Zac-HD.
First solution:
Put
@settings(print_blob=True)
before a test. This will ensure that you'll get a hint how to reproduce a potential error.Second solution:
Register a settings profile (e.g. in your
conftest.py
):All about
settings
can be found in the official docs: https://hypothesis.readthedocs.io/en/latest/settings.html