Test Overview
This test demonstrates how to use @pytest.mark.skipif to skip a test when a specific condition is true. It verifies that the test is skipped when the condition matches.
This test demonstrates how to use @pytest.mark.skipif to skip a test when a specific condition is true. It verifies that the test is skipped when the condition matches.
import sys import pytest @pytest.mark.skipif(sys.platform == "win32", reason="Skip on Windows") def test_not_on_windows(): assert True
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Pytest starts test collection and identifies test_not_on_windows with skipif condition | Test suite ready to run, current platform detected as Linux | - | PASS |
| 2 | Pytest evaluates skipif condition sys.platform == 'win32' | Condition evaluates to False on Linux | - | PASS |
| 3 | Pytest runs test_not_on_windows function | Test executes normally | assert True | PASS |
| 4 | Test completes successfully without skipping | Test passed | - | PASS |