Python reference

pytest
cheat sheet.

pytest collection, assertions, fixtures, parametrization, mocks, async tests, plugins, and command-line options.

26 topics60 code examplesUpdated
How pytest fits together
01WriteName a function test_* and assert a result.
02Collectpytest discovers files and test cases.
03Set upFixtures supply reusable test data.
04ReportEach case passes, fails, skips or errors.
Jump to a specific topic

Choose a chapter

4 chapters · 26 topics

CHAPTER 01 / 04

Fixtures, assertions, and parametrization

Write pytest assertions, fixtures, and parametrized tests. Examples cover fixture scope, teardown, temporary files, monkeypatch, and test selection.

12 topics