Skip
The skip tag allows us to mark test functions to be skipped during test execution.
When a test is skipped, it will not be run but will be counted in the test results.
Basic Usage
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.
Running skipped tests
Use --run-ignored=only to run only tests whose skip condition is active, or
--run-ignored=all to run them alongside normal tests. Active skip decorators
are ignored for these tests, so their bodies run and can pass or fail normally.
| Bash | |
|---|---|
1 2 | |
Tests with false skip conditions are not considered ignored.
Reason
You can provide a str reason as a positional or keyword argument.
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.
Pytest
You can also still use @pytest.mark.skip.
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.
Conditions
We can provide bool conditions as a positional arguments.
Then the test will only be skipped if all conditions are True.
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.
You can still provide a reason as a keyword argument.
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.
Multiple Conditions
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one failed test.
Pytest
You can also still use @pytest.mark.skipif.
| test.py | |
|---|---|
1 2 3 4 5 | |
Then running uv run karva test will result in one skipped test.