pytest-ignore-test-results

0.3.0 · active · verified Thu Apr 16

pytest-ignore-test-results is a pytest plugin that enables selective test result ignoring while maintaining test execution. It allows users to specify test cases (by name or pattern) whose failures should not result in a non-zero exit code from pytest. The current version is 0.3.0, and it is actively maintained by Espressif, with releases occurring as needed for updates and new features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `pytest-ignore-test-results` via command-line arguments to selectively ignore test failures. It shows how to specify individual test cases or patterns, load ignore lists from files, and control exit codes for CI/CD pipelines. Note that ignored tests still execute.

# First, ensure you have pytest and the plugin installed:
# pip install pytest pytest-ignore-test-results

# Create a test file (e.g., test_example.py)
# ----------------------------------------
# def test_passing():
#     assert True
#
# def test_failing_critical():
#     assert False, "This test MUST NOT be ignored"
#
# def test_failing_but_ignorable():
#     assert False, "This test's failure can be ignored"
# ----------------------------------------

# Run pytest, ignoring the result of 'test_failing_but_ignorable':
# The test will still run, but its failure won't cause pytest to exit with a non-zero code
# unless --strict-exit-code is used and ALL failures are ignored.
# Expected output will show 'xfailed' or 'ignored' for the specified test.

print("Run with: pytest --ignore-result-cases 'test_failing_but_ignorable' test_example.py")
# Example of ignoring tests based on a pattern:
print("Run with: pytest --ignore-result-cases 'test_failing_*' test_example.py")

# Example of loading ignore patterns from a file (e.g., ignore_list.txt):
# Content of ignore_list.txt:
# test_failing_but_ignorable
# test_feature_*
print("Run with: pytest --ignore-result-files ignore_list.txt test_example.py")

# To exit with code 6 if all failed tests are ignored:
print("Run with: pytest --ignore-result-cases 'test_failing_but_ignorable' --strict-exit-code test_example.py")

view raw JSON →