Python Testing Skill
Rules
- Use pytest as the test framework — never
unittest. - Aim for ≥90% line coverage on all new code.
- Use
pytest.fixturefor shared setup; avoidsetUp/tearDownmethods. - Name test files
test_<module>.pyand test functionstest_<behavior>. - Use
pytest.mark.parametrizefor data-driven tests. - Mock external dependencies with
unittest.mock.patch— never hit real APIs in tests.