How to prevent PytestCollectionWarning when testing class Testament via pytest

You can run pytest with the following flag:

-W ignore::pytest.PytestCollectionWarning

This is just the "normal" warning filter for python, according to the documentation:

Both -W command-line option and filterwarnings ini option are based on Python’s own -W option and warnings.simplefilter


You can set a __test__ = False attribute in classes that pytest should ignore:

class Testament:
    __test__ = False

Tags:

Python

Pytest