npx skills add ...
npx skills add microsoft/debugpy --skill pytest
npx skills add microsoft/debugpy --skill pytest
Best practices for writing and organizing tests with pytest including fixtures, parametrize, and plugins.
Best practices for writing and organizing tests with pytest including fixtures, parametrize, and plugins.
Apply this skill when writing and organizing tests with pytest โ fixtures, parametrize, markers, plugins, and test structure.
tests/ directory mirroring the source structure.test_<module>.py and test functions test_<behavior>().function > class > module > session).conftest.py for shared fixtures; put it at the appropriate directory level.yield fixtures for setup/teardown; prefer tmp_path over tempfile.@pytest.mark.parametrize for data-driven tests with multiple inputs.ids=...) for readable test output.parametrize with fixtures for cross-product testing.assert statements โ pytest rewrites them for clear failure messages.pytest.raises(ExceptionType, match=...) for exception testing.pytest.approx() for floating-point comparisons.pytest-cov, pytest-mock, pytest-asyncio, pytest-xdist, pytest-timeout.pytest-mock's mocker fixture over raw unittest.mock.patch.session-scoped fixtures for mutable state.