How to see the output of Python's hypothesis library

See here - either the note function and --hypothesis-verbosity=verbose, or the event function and --hypothesis-show-statistics should do the trick.


You could put a print statement or logging statement before the assert:

import logging
from hypothesis import given
import hypothesis.strategies as st

log_filename = 'debug.log'
logging.basicConfig(filename=log_filename, level=logging.DEBUG)
logger = logging.getLogger(__name__)

@given(st.integers())
def silly_example(some_number):
    logger.debug('silly_example(%s) called', some_number)
    assert some_number > 0

By using logging instead of print statements, you can turn off all logging simply by changing the logging level. If you change logging.DEBUG to logging.INFO:

logging.basicConfig(filename=log_filename, level=logging.INFO)

then logger.debug will no longer emit records.