Registry / testing / pytest-integration

pytest-integration

JSON →
library0.2.3pypypi✓ verified 82d ago

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.

pip install pytest-integration
INSTALL
IMPORT
SIG · PYTEST-INTEGRATION
P
pytest-integration
testingpythonv0.2.3
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest_integration
import pytest_integration
from pytest_integration import pytest

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.

import pytest def test_unit_example(): assert 1 + 1 == 2 @pytest.mark.integration_test def test_integration_example(): # Simulate an integration call assert 'integration' in 'this is an integration test' @pytest.mark.slow_integration_test def test_slow_integration_example(): # Simulate a slow integration call assert True # To run: pytest --with-integration --with-slow-integration
pytest --version
Debug
Known issues
gotchaWhen 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.
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.
affects: All versions
gotchaIf `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.
fix
To include integration tests in coverage reporting, use the `--integration-cover` command-line option when running pytest. Example: `pytest --with-integration --integration-cover`.
affects: All versions
deprecatedDirect 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`.
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.
affects: All versions (pytest 5.0+ related changes)
Upgrade
Version history
0.2.3latest on PyPI · released Nov 17, 2022
Audit
Dependencies
pytestrequiredCore testing framework that this plugin extends.
pytest-covoptionalIf installed, pytest-integration disables coverage for integration tests by default.
Agent activity
14 hits · last 30 days
node
14
Resources
pytest-integration — pip install pytest-integration · libregistry