pytest
pytest Exit Codes
Exit codes returned by the pytest test framework after a test run. CI systems use these to determine whether a build should pass or fail.
6 codes
· All codes 6 codes
- 0 OK All collected tests passed (or were xfailed/xpassed as expected). The test suite completed successfully.
- 1 Tests Failed Tests were collected and run, but one or more tests failed or raised an unexpected error. Review the test output for FAILED and ERROR entries, then fix the failing tests or assertions.
- 2 Interrupted Test execution was interrupted before completion — typically by Ctrl+C or a SIGINT signal, or by a plugin calling `pytest.exit()`. Any results collected before the interruption are still reported.
- 3 Internal Error An unexpected internal error occurred inside pytest itself (not in user test code). This usually indicates a bug in pytest or a plugin. Check the traceback shown, update pytest and any plugins, and report the issue upstream if it persists.
- 4 Usage Error pytest was invoked with invalid command-line options or configuration. Check the argument syntax, verify that all specified paths and markers exist, and consult `pytest --help` for correct usage.
- 5 No Tests Collected pytest ran successfully but found no tests matching the given criteria. Check that test files match the `python_files` pattern (default: `test_*.py` / `*_test.py`), that test functions are prefixed with `test_`, and that any `-k` or `-m` filters are not too restrictive.