Testing with pytest
The pytest testing framework in depth: fixtures, parametrization, mocking, coverage, and configuration. Assumes you already know Python (see this library's python-basics course) and general testing vocabulary (see testing-in-software-engineering) — this course is about the pytest tool itself.
pytestpythontestingqaintermediate
Get Yaaddi on Google Play Free. Install the app, then add this course from its Course Library.
View this course's repo on GitHub → — star it, open an issue, or suggest a fix.
24decks
45main cards
305practice cards
0%with images
v1.1.4version
Card type mix
- multiple choice: 168
- true false: 128
- select blank: 53
- match pairs: 12
- code fill: 11
- short answer: 10
- order: 4
- multi select: 4
- categorize: 2
- command output: 1
What's covered
- What pytest Is and Why It Replaced unittest
- Installing pytest and Running Your First Test
- Test Discovery Conventions
- Writing Assertions with Plain assert
- Assertion Rewriting and Failure Messages
- Fixtures Fundamentals
- Fixture Scopes
- conftest.py and Fixture Sharing
- Built-in Fixtures: tmp_path, capsys, monkeypatch
- Yield Fixtures and Teardown
- Parametrizing Tests
- Parametrizing Fixtures
- Marking Tests: skip, skipif, xfail
- Custom Markers and Registration
- Testing Exceptions with pytest.raises
- Testing Warnings with pytest.warns
- Mocking with pytest-mock
- Measuring Coverage with pytest-cov
- Running Tests in Parallel with pytest-xdist
- Configuring pytest: pyproject.toml and ini Options
- Organizing a Test Suite: src Layout
- Debugging Failing Tests: -v, -x, -k, --pdb
- Common pytest Anti-Patterns and Best Practices
- Recap: Key Terms
Example cards
multiple choice
pytest tests are written as:
multiple choice
pytest checks results using:
Latest: Wording fixes so cards do not use terms before they are taught and practice cards mention their topic.