I am using environment variables to control some Hypothesis settings in conftest.py
:
test_max_examples = int(os.environ.get("TEST_MAX_EXAMPLES", "100").strip())
hypothesis.settings.register_profile(
"dev",
print_blob=True,
max_examples=test_max_examples,
)
hypothesis.settings.load_profile("dev")
I would like to print these settings for the user's benefit, before running the tests.
However, my naive attempt failed, because Pytest captures output:
print(hypothesis.settings.get_profile("dev"))
I am aware that the capsys
fixture can be used inside tests to bypass output capturing, but I don't believe fixtures can be used at the top level of conftest.py
.
Is there another solution to this? Or is this some kind of antipattern, and I'm not able to do this for a good reason?
I do not want to require the use of -s
in Pytest unconditionally.