Pytest rerun/retry class if any test inside the class fails
pytest retry failure
https://pypi.org/project/pytest-retry-class/0.2.0/
pip install pytest-retry-class
pytest --maxretry 2 --retry_on_exception "[AssertionError, DBError]" test.py
Where:
--maxretry
is the number of times to retry a failed test [default: 1]--retry_on_exception
is a list of exceptions to retry on [default: all exceptions]
You can also set the retry count and exceptions in pytest.ini file
[pytest]
maxretry = 2
retry_on_exception = AssertionError
DBError
Warning: CMD line arguments will override the pytest.ini file.
pytest example/pytest-xdist-support/tests
pytest example/pytest-dependency-support/tests
pytest example/rerun-class/tests