{"id":4211,"library":"pytest-assume","title":"pytest-assume","description":"pytest-assume is a pytest plugin that enhances test assertion behavior by allowing multiple failures within a single test. Instead of stopping test execution on the first failed assertion, it collects all failures reported via `pytest.assume()` and reports them at the end of the test, providing a comprehensive view of all issues. The current version is 2.4.3, with a regular release cadence addressing bug fixes and compatibility improvements.","status":"active","version":"2.4.3","language":"en","source_language":"en","source_url":"https://github.com/astraw38/pytest-assume","tags":["pytest","testing","assertions","multiple failures","test runner","plugin"],"install":[{"cmd":"pip install pytest-assume","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"pytest is the core test framework this plugin extends.","package":"pytest","optional":false}],"imports":[{"note":"pytest.assume() is exposed directly by the plugin once installed; no direct import from 'pytest_assume' module is typically needed for core functionality.","symbol":"pytest.assume","correct":"import pytest\n# ... use pytest.assume()"}],"quickstart":{"code":"import pytest\n\ndef test_multiple_conditions():\n    # These assumptions will all be evaluated,\n    # and all failures reported at the end of the test.\n    pytest.assume(1 == 1, \"This assumption should pass\")\n    pytest.assume(2 == 3, \"Expected 2 to be 3, but it was not!\")\n    pytest.assume(\"hello\" == \"hello\", \"String comparison should pass\")\n    pytest.assume(5 > 10, \"5 is not greater than 10\")\n\n    # Using the context manager for a group of assumptions\n    with pytest.assume:\n        pytest.assume(True, \"Context manager assumption 1 (pass)\")\n        pytest.assume(False, \"Context manager assumption 2 (fail)\")\n\n    # A standard assert would halt the test here if it failed,\n    # but pytest.assume allows execution to continue.\n    assert 1 == 1 # This line is reached even if pytest.assume() calls failed","lang":"python","description":"This example demonstrates how to use `pytest.assume()` directly and with the `with pytest.assume:` context manager. All `assume` calls within a test function are executed, and any failures are reported at the end, unlike standard `assert` statements that stop execution immediately."},"warnings":[{"fix":"Be mindful of this execution flow. If immediate halting is desired, use standard `assert` statements instead of `pytest.assume()` for critical conditions, or structure tests to run different failure types in separate functions.","message":"Unlike standard Python `assert` statements, `pytest.assume()` does not immediately halt test execution upon failure. Its core purpose is to allow tests to continue running and collect all failures before reporting them at the end. This can be a surprise for users expecting traditional assertion behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Thoroughly test `pytest-assume` in your specific plugin environment. If unexpected behavior occurs, consult the `pytest-assume` GitHub issues or documentation, and consider using the latest version of the plugin and pytest itself.","message":"pytest-assume has historically had nuanced interactions with other pytest plugins, particularly those that modify hook execution order or capture output (e.g., log capturing). While recent versions (e.g., 2.4.3) include fixes like `tryfirst=True` for specific hooks, conflicts can still arise. Previous versions also saw changes to internal pytest hooks used (e.g., 2.1.0, 2.4.0).","severity":"gotcha","affected_versions":"<=2.4.2 (specifically for log capture), but generally across all versions for potential hook conflicts."},{"fix":"Ensure you are using `pytest-assume` version 2.4.1 or newer for improved `xfail` compatibility. Test your `xfail` cases carefully to confirm expected behavior.","message":"When using `pytest-assume` with `xfail` markers, there have been bug fixes in how `xfail` conditions are handled in conjunction with multiple assumptions. While version 2.4.1 addressed specific bugs, unexpected interactions might still occur with complex `xfail` configurations.","severity":"gotcha","affected_versions":"<2.4.1"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}