Skip to content
  1. All topics
  2. Python
  3. Testing
Sections

Python · Section 14

Testing

The test pyramid, pytest's fixtures/parametrization/marks, unittest.mock's Mock/patch/AsyncMock, and the quality practices — coverage, isolation, determinism — that decide whether a test suite can actually be trusted. The roadmap calls testing "a major competency at this level."

This section
Python Tutorial: Unit Testing Your Code with the unittest ModuleCorey Schafer
  1. Test typesThe test pyramid — unit, integration, API, and end-to-end tests — plus three more specialized types: regression, contract, and performance tests.1 core1 standard2 concepts
  2. pytestDiscovery and plain-assert assertions, fixtures and their scopes, parametrization, marks and plugins, and async tests via conftest.py-shared configuration.2 core3 standard5 concepts
  3. Mockingunittest.mock's Mock, MagicMock, patch, and AsyncMock; monkeypatching; the vocabulary of test doubles (stubs, spies, fakes); and the roadmap's own "most importantly" rule — knowing what should and should not be mocked.3 core2 standard5 concepts
  4. QualityWhat makes a test suite trustworthy beyond "the tests pass" — coverage, isolation, determinism, database/external-service test isolation, and deliberately testing failure scenarios.3 core1 standard4 concepts
Previous13. Async PythonNext15. Python Packaging