pytest Tips and Tricks for a Better Test Suite
by Freya Bruhin
Monday, 19 April 2027, 9:00–16:00 (lunch break 12:00–13:00) · 6 hours
pytest Tips and Tricks for a Better Test Suite — Full-Day Masterclass
pytest lets you write simple tests fast, but also scales to very complex scenarios. Beyond the basics of no-boilerplate test functions, this comprehensive full-day masterclass will dive deep into various intermediate and advanced pytest features, as well as gems and tricks.
The masterclass format allows time for hands-on exercises, real-world examples and Q&A.
Who Should Attend
To attend this masterclass, you should already be familiar with the pytest basics (e.g. writing test functions, parametrize, or what
a fixture is) and want to learn how to take the next step to improve your test suites.
If you're already familiar with things like fixture caching scopes, autouse, or using the built-in tmp_path/monkeypatch/...
fixtures: there will probably be some slides about concepts you already know, but there are also various little hidden tricks and gems
to discover.
What You'll Learn
- Recommended pytest settings for more strictness
- What
xfailis and why it is useful - How to mark an entire test file or single parameters
- Ways to deal with parametrize IDs and syntax
- Useful built-in pytest fixtures
- Caching for fixtures, cleanup from fixtures, using fixtures implicitly
- Advanced fixture and parametrization topics, like how to customize fixture behavior based on markers or custom CLI arguments
- Mocking: how to do so effectively and when not to mock
- Various tips and tricks around debugging failing tests
- The plugin ecosystem around pytest and how to write your own plugins
- Property-based testing with Hypothesis
What to Bring
A laptop with pytest and Hypothesis installed — nothing else.
Your trainer: Freya Bruhin
Freya Bruhin ("The Compiler") is a long-time contributor and maintainer of both the pytest framework and various plugins. Discovering pytest in 2015, Freya has since given talks and conducted workshops about pytest at various conferences and companies. Freya's main project, qutebrowser (a keyboard-focused web browser), has grown from a hobby to a donation-funded part-time job.
- bruhin.software
- pytest: pytest.org · GitHub
- qutebrowser: qutebrowser.org · GitHub