pytest Fundamentals
Write and run tests with pytest — the most popular Python testing framework. Test functions, classes, and edge cases confidently.
Mocking APIs, Files, and Commands
Use unittest.mock and pytest-mock to replace external dependencies in tests — API calls, file I/O, databases, and shell commands.
Debugging, Profiling, and Linting
Find and fix bugs faster with pdb and breakpoint(), measure performance with cProfile, and catch issues before runtime with linting tools.
Test Fixtures and Temp Files
Use pytest fixtures to share test setup, create temporary files and directories, and manage test state cleanly.
Static Analysis and Formatting
Use ruff, mypy, and black to automatically find bugs, enforce style, and keep code quality consistent across a team.