pytest
- Category
- Frameworks and libraries
- Docs outline
- 16 sections
Official docs outline
docs.pytest.org- Get Started
Writing a first test, assertions, running tests, grouping tests in classes, and test discovery.
- Invoking pytest
Command line options, selecting tests by node ID, keyword or marker, -x, --lf, and exit codes.
- Assertions
Plain assert rewriting, pytest.raises, approx, expected exceptions, and custom assertion explanations.
- Fixtures
Defining fixtures, scopes, yield teardown, autouse, fixture factories, conftest.py, and fixture overriding.
- Anatomy of a Test and About Fixtures
Arrange-act-assert-cleanup phases and how fixtures structure tests and dependencies.
- Marks
Custom markers, registering markers, and selecting tests with -m.
- Parametrization
pytest.mark.parametrize, parametrized fixtures, indirect parametrization, and ids.
- Skip and xfail
skip, skipif, xfail, strict xfail, and conditional test outcomes.
- Temporary Directories and Files
tmp_path, tmp_path_factory, and test isolation with file systems.
- Monkeypatching and Mocking
monkeypatch fixture, setattr, setenv, patching dictionaries, and isolating tests from the environment.
- Capturing Output, Logging and Warnings
capsys and capfd, caplog, recwarn, pytest.warns, and output control.
- Plugins and Hooks
conftest.py plugins, hook functions, installing and writing plugins, and plugin discovery.
- unittest and xunit-style Setup
Running unittest.TestCase tests, setup_method/teardown_method, and mixing styles.
- Good Integration Practices
Project layout, src layout, test discovery conventions, editable installs, and tox.
- Flaky Tests and CI
Causes of flaky tests, rerunning, random ordering, and CI pipeline setup.
- Reference Guides
Built-in fixtures, marks, configuration options, hooks, and exit codes.
Each section links to the official page. Titles and summaries by Extra Credit; the docs belong to their authors.