{"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":"python","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,"search_vec":"'2.8.0':54 'activ':59 'allow':16 'assert':18,36,67 'cadenc':61 'check':2,5,40 'collect':38 'current':51 'end':46 'execut':29 'extend':11 'fail':32 'failur':19 'first':35 'function':14,24 'immedi':26 'instead':30 'maintain':57 'multipl':17 'plugin':9,71 'pytest':1,4,8,13,65 'pytest-check':3 'regular':63 'releas':60 'report':42 'runner':70 'singl':22 'standard':12 'stop':27 'test':23,28,49,66,69 'test-runn':68 'updat':64 'version':52 'within':20 'without':25","created_at":"2026-04-11T01:39:58.650530+00:00","updated_at":"2026-04-16T19:57:59.505827+00:00","problems":[{"fix":"Install the library using pip: `pip install pytest-check`","cause":"The `pytest-check` library is not installed in the active Python environment or is not accessible to pytest.","error":"ModuleNotFoundError: No module named 'pytest_check'"},{"fix":"Ensure `pytest-check` is installed (`pip install pytest-check`) and run your tests using the `pytest` command (e.g., `pytest your_test_file.py`).","cause":"The `check` object, which provides assertion functions, is injected by the `pytest-check` plugin and is only available when tests are run using `pytest`. This error occurs if you try to execute a test file directly with Python or if the plugin is not properly installed or activated.","error":"NameError: name 'check' is not defined"},{"fix":"Remove the `import` statement (e.g., `from pytest_check import check`) and use `check.equal(...)` (or other `check` functions) directly within your test functions.","cause":"The `check` object, which provides assertion functions like `equal` and `check_that`, is automatically injected into test functions by the `pytest-check` plugin and is not meant to be imported directly from the `pytest_check` package.","error":"ImportError: cannot import name 'check' from 'pytest_check'"},{"fix":"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.","cause":"You are trying to access `check` assertion functions directly through the `pytest_check` module, but these functions are part of the `check` object injected by the plugin, not the top-level module itself.","error":"AttributeError: module 'pytest_check' has no attribute 'equal'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.9.1","cli_name":"pytest","cli_version":"pytest 9.0.3","type":"library","homepage":null,"github":"https://github.com/okken/pytest-check","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytest-check/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}