{"id":2720,"library":"pytest-check","title":"Pytest Check","description":"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.","status":"active","version":"2.8.0","language":"en","source_language":"en","source_url":"https://github.com/okken/pytest-check","tags":["pytest","testing","assertions","test-runner","plugin"],"install":[{"cmd":"pip install pytest-check","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core testing framework that pytest-check extends.","package":"pytest","optional":false}],"imports":[{"note":"The pattern `import pytest_check as check` for accessing helper functions (e.g., `check.equal()`) is deprecated and will be removed in a future version. Use `from pytest_check import check` or request `check` as a fixture (e.g., `def test_my_func(check):`).","wrong":"import pytest_check as check","symbol":"check","correct":"from pytest_check import check"}],"quickstart":{"code":"import httpx\nfrom pytest_check import check\n\ndef test_httpx_get():\n    # This assert will stop the test immediately if it fails\n    r = httpx.get('https://www.example.org/')\n    assert r.status_code == 200\n\n    # These 'checks' will all run, collecting failures, \n    # even if one of them fails\n    with check: \n        assert r.is_redirect is False\n    with check: \n        assert r.encoding == 'utf-8'\n    with check: \n        assert 'Example Domain' in r.text\n    \n    # pytest-check also provides helper functions for common assertions\n    check.equal(r.status_code, 200, msg='Status code not 200')\n","lang":"python","description":"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."},"warnings":[{"fix":"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):`).","message":"The import pattern `import pytest_check as check` for using helper functions (e.g., `check.equal()`, `check.is_true()`) is deprecated. While it currently works, it will be removed in a future major version without a deprecation warning being emitted.","severity":"deprecated","affected_versions":"2.x"},{"fix":"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.","message":"The default behavior for displaying pseudo-tracebacks changed in version 2.x. Only the first failure per test will now include a pseudo-traceback by default (`--check-max-tb=1`). Previously, more might have been shown.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"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`.","message":"The pseudo-tracebacks used by `pytest-check` for multiple failures are generated via introspection, which can be slower than standard assert tracebacks. Limiting the number of pseudo-tracebacks (via `--check-max-tb`) is a performance optimization.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}