Test Overview
This test uses a custom marker to categorize a test case. It verifies that the test runs only when the marker is used and that the assertion inside the test passes.
This test uses a custom marker to categorize a test case. It verifies that the test runs only when the marker is used and that the assertion inside the test passes.
import pytest @pytest.mark.slow def test_addition(): result = 2 + 3 assert result == 5
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Pytest starts test collection and identifies test_addition with custom marker 'slow'. | Test suite is ready to run tests with markers. | — | PASS |
| 2 | Pytest runs test_addition marked with @pytest.mark.slow. | Inside test_addition function, calculation 2 + 3 is performed. | — | PASS |
| 3 | Assertion checks if result equals 5. | Variable result holds value 5. | assert result == 5 | PASS |
| 4 | Test test_addition completes successfully. | Test marked 'slow' passed. | — | PASS |
slow?pytest -m slow?
import pytest
@pytest.mark.slow
def test_a():
assert True
def test_b():
assert True
@pytest.mark.slow
def test_c():
assert False
pytest -m slow doesimport pytest
@pytest.mark.slow()
def test_example():
assert True
database but exclude those also marked as slow. Which pytest command achieves this?Pass the test and this pattern moves unknown