How best to initialize in unit tests?

Skip Montanaro skip.montanaro at gmail.com
Wed Oct 4 10:20:26 EDT 2017


> I've not had this problem myself, but py.test has the idea of "autouse
> fixtures" which would work for this situation. Define your setup call
> in a function, declare it with the pytest.fixture decorator with
> autouse=True, and it'll be run before every test. The declaration goes
> in a conftest.py file alongside your test files.

Thanks. I'm not a py.test user, but it turns out that nose (which I do
use) appears
to have something similar:

https://nose.readthedocs.io/en/latest/doc_tests/test_init_plugin/init_plugin.html

Thanks for the nudge in the right direction.

Skip



More information about the Python-list mailing list