{"id":8533,"library":"pytest-integration","title":"Pytest Integration","description":"pytest-integration is a plugin for pytest that allows users to organize tests into 'unit', 'integration', and 'slow integration' categories. It ensures that integration tests run only after unit tests, and slow integration tests run after quick integration tests, stopping execution of later stages if earlier ones fail. When `pytest-cov` is installed, it automatically disables code coverage for integration tests, assuming unit tests handle comprehensive coverage. The current version is 0.2.3, last released on November 17, 2022, suggesting a low-activity or stable maintenance phase.","status":"maintenance","version":"0.2.3","language":"en","source_language":"en","source_url":"https://github.com/jbwdevries/pytest-integration","tags":["pytest","testing","integration testing","plugin","test organization"],"install":[{"cmd":"pip install pytest-integration","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core testing framework that this plugin extends.","package":"pytest","optional":false},{"reason":"If installed, pytest-integration disables coverage for integration tests by default.","package":"pytest-cov","optional":true}],"imports":[{"note":"This marker is registered by the plugin and used to mark quick integration tests.","symbol":"@pytest.mark.integration_test","correct":"import pytest\n\n@pytest.mark.integration_test\ndef test_something_integrated():\n    ..."},{"note":"This marker is registered by the plugin and used to mark slow integration tests.","symbol":"@pytest.mark.slow_integration_test","correct":"import pytest\n\n@pytest.mark.slow_integration_test\ndef test_something_slow_integrated():\n    ..."}],"quickstart":{"code":"import pytest\n\ndef test_unit_example():\n    assert 1 + 1 == 2\n\n@pytest.mark.integration_test\ndef test_integration_example():\n    # Simulate an integration call\n    assert 'integration' in 'this is an integration test'\n\n@pytest.mark.slow_integration_test\ndef test_slow_integration_example():\n    # Simulate a slow integration call\n    assert True\n\n# To run: pytest --with-integration --with-slow-integration","lang":"python","description":"Define tests with `@pytest.mark.integration_test` or `@pytest.mark.slow_integration_test`. Run pytest with `--with-integration` to include quick integration tests and `--with-slow-integration` to include slow integration tests. Unit tests run by default. If a unit test fails, integration tests are skipped. If an integration test fails, slow integration tests are skipped."},"warnings":[{"fix":"Be aware of `xdist` behavior. If strict sequential execution across *all* tests (not just within a single node's collected tests) is critical, consider running without `xdist` or designing tests to be fully isolated.","message":"When using `pytest-xdist`, each node will collect and run tests independently based on its index. This can lead to situations where integration tests might still run on a node even if a unit test failed on another node, potentially masking cross-node dependencies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To include integration tests in coverage reporting, use the `--integration-cover` command-line option when running pytest. Example: `pytest --with-integration --integration-cover`.","message":"If `pytest-cov` is installed, `pytest-integration` automatically disables code coverage collection for all integration and slow integration tests by default. This is based on the assumption that unit tests should provide full code coverage.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always invoke pytest directly (e.g., `pytest` or `python -m pytest`) rather than through `setup.py`. Refer to `pytest-runner` notice and `pypa/setuptools#1684` for more details and migration instructions.","message":"Direct integration with `setuptools` (e.g., using `python setup.py test` or `pytest-runner`) is not recommended by the core pytest project and may stop working in the future. This applies to any pytest plugin, including `pytest-integration`.","severity":"deprecated","affected_versions":"All versions (pytest 5.0+ related changes)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure relevant tests have the correct markers. Run pytest with `pytest --with-integration` to execute quick integration tests, and `pytest --with-slow-integration` for slow integration tests. By default, only unit tests (without these markers) run.","cause":"Tests might not be correctly marked with `@pytest.mark.integration_test` or `@pytest.mark.slow_integration_test`, or the corresponding command-line options (`--with-integration`, `--with-slow-integration`) are missing.","error":"No tests were collected or integration tests are not running."},{"fix":"To include coverage from integration tests, add the `--integration-cover` flag to your pytest command: `pytest --with-integration --integration-cover`.","cause":"The `pytest-integration` plugin, by default, disables coverage collection for tests marked as `integration_test` or `slow_integration_test` when `pytest-cov` is active.","error":"Code coverage report is missing data from integration tests even though they ran successfully."}]}