The documentation for py.test says that py.test implements the following standard test discovery:
- collection starts from the initial command line arguments which may be directories, filenames or test ids.
recurse into directories, unless they match norecursedirs - test_*.py or *_test.py files, imported by their package name.
Test
prefixed test classes (without an__init__
method) [<– notice this one here]test_
prefixed test functions or methods are test items
So it’s not that the constructor isn’t needed, py.test just ignores classes that have a constructor. There is also a guide for changing the standard test discovery.