Pytest Integration

0.2.3 · maintenance · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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

view raw JSON →