Troubleshooting¶
This section helps you diagnose and fix common issues with pytest-test-categories.
Topics¶
Common Issues¶
Tests Missing Size Markers¶
Symptom:
PytestWarning: Test 'test_something' has no size marker.
Solution: Add a size marker to your test:
@pytest.mark.small # or medium, large, xlarge
def test_something():
pass
Or use a base test class:
from pytest_test_categories import SmallTest
class TestMyFeature(SmallTest):
def test_something(self):
pass
Timing Violations¶
Symptom:
TimingViolationError: Test exceeded time limit
Test: test_slow_operation
Size: SMALL
Duration: 2.34 seconds
Limit: 1.00 second
Solutions:
Optimize the test: Remove unnecessary operations, use mocks
Change test size: If the test legitimately needs more time, use
@pytest.mark.mediumSplit the test: Break into smaller, focused tests
Distribution Warnings¶
Symptom:
WARNING: Test distribution outside target range.
Small tests: 65% (target: 80% +/- 5%)
Solutions:
Review which tests could be converted to smaller categories
Mock external dependencies instead of using real ones
Use dependency injection for testability
Plugin Not Loading¶
Symptom: Tests run but no size markers are recognized.
Solutions:
Verify installation:
pip show pytest-test-categories
Check pytest plugins:
pytest --co -q # Should show [SMALL], [MEDIUM], etc. labels
Verify entry point in pyproject.toml:
[project.entry-points.pytest11] test_categories = "pytest_test_categories.plugin"
Conflicts with Other Plugins¶
If pytest-test-categories conflicts with another plugin:
Check pytest plugin order:
pytest --trace-configTry adjusting hook order with
tryfirst=Trueortrylast=TrueReport the conflict as a GitHub issue
Getting Help¶
If you encounter an issue not covered here:
Search existing issues
Check GitHub Discussions
Open a new issue with:
pytest-test-categories version
pytest version
Python version
Minimal reproduction case
Full error message