pytest-check is a pytest plugin that extends standard pytest functionality to allow multiple assertion failures within a single test function without immediately stopping test execution. Instead of failing on the first `assert`, it collects all 'checks' and reports them at the end of the test. The current version is 2.8.0, and it maintains an active release cadence with regular updates.
pip install pytest-checkVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `pytest-check` with both its `with check:` context manager for standard assertions and its direct helper functions like `check.equal()`. A normal `assert` outside of `with check:` will stop the test immediately, while checks inside the context manager or using `check.` methods will collect all failures before reporting them at the end of the test.
Change imports to `from pytest_check import check` or pass `check` as a fixture to your test functions (e.g., `def test_my_func(check):`).
If you require more pseudo-tracebacks for debugging, configure the `--check-max-tb=N` command-line option, where `N` is the desired number of tracebacks. Setting it to a large number like 1000 will show all.
Be mindful of performance if `--check-max-tb` is set to a very high number in test suites with many failures. The default of 1 is chosen for speed. You can also limit the total reported failures per test with `--check-max-report=N`.
Install the library using pip: `pip install pytest-check`
Ensure `pytest-check` is installed (`pip install pytest-check`) and run your tests using the `pytest` command (e.g., `pytest your_test_file.py`).
Remove the `import` statement (e.g., `from pytest_check import check`) and use `check.equal(...)` (or other `check` functions) directly within your test functions.
Remove `import pytest_check` and use `check.equal(...)` (or other `check` functions) directly within your test functions. The `check` object is made available implicitly by the plugin.