Skip to main content This is the website for an older EuroPython. Looking for the latest EuroPython? Click here!
EuroPython logo

Pytest Design Patterns

Track:
Testing and QA
Type:
Talk
Level:
intermediate
Room:
North Hall
Start:
11:55 on 12 July 2024
Duration:
30 minutes

Abstract

Proper testing of your Python application doesn’t require a rewrite into hexagonal architecture (whatever it means 🤷). In this session, we’ll explore battle-tested techniques to enhance the maintainability of your test suite.

  • Embracing Well-Known Patterns: The test client or transaction-bound tests are well-established patterns originating from Django. We will explore how to extend these foundational practices within pytest.
  • Employing Fixture Factories: How to ensure that our test data clearly cover the intended scenarios? Unpack the utility of fixture factories, streamlining the setup process.
  • Mocking without Monkey Patching: Learn effective mocking, steering clear of the problematic practice of monkey patching. We’ll explore strategies to achieve accurate testing using favorite frameworks and libraries.
  • Covering More with Parametrized Fixtures: Many developers are familiar with pytest fixtures and parametrized tests, but may not be aware of the power of their combination: parametrized fixtures. Discover how to easily build more comprehensive tests.
  • Rethinking Test Categorization: The traditional division into unit and integration tests often falls short in practical application. We’ll check an alternative approach that can better align with real-world scenarios.

The goal is not merely to report higher coverage but to have tests that can be trusted. By incorporating established patterns, you’ll be empowered to focus on what truly matters.

Recording

Play

Resources