Learn unittest
Python's built-in xUnit-style testing framework, with mocking included
unittest is the testing framework that ships with Python: test case classes, rich assertions, fixtures, test discovery and a runner, plus unittest.mock for replacing dependencies. It needs no installation, CPython itself is tested with it, and pytest runs unittest tests unchanged. Learning it gives you dependable tests anywhere Python runs.
Before you start
How deep do you want to go?
1. EssentialsRead and write simple code, do the everyday basics
2. PracticalUse it productively at work, with the usual idioms
3. AdvancedThe less common features, performance and trade-offs
4. ExpertInternals and the edge cases experts know