Why PyTest is not collecting tests (collected 0 items)?

pytest gathers tests according to a naming convention. By default any file that is to contain tests must be named starting with test_, classes that hold tests must be named starting with Test, and any function in a file that should be treated as a test must also start with test_.

If you rename your test file to test_sorts.py and rename the example function you provide above as test_integer_sort, then you will find it is automatically collected and executed.

This test collecting behavior can be changed to suit your desires. Changing it will require learning about configuration in pytest.

Leave a Comment