PyCon CZ

PyCon CZ 23
15–17 September

Pytest: The Case for Using Classes a talk by Mikuláš Poul

Saturday 16 September 11:10 (30 minutes)

There's many reasons why people love pytest – the simple asserts, modular test setup, easy barrier to entry, the plugin ecosystem.

But at scale, only using function-based tests becomes hard to maintain, and slow to run. At Xelix, our main Django monolith has about ten thousand tests and about four thousand fixtures, so speed and maintainability is of paramount importance.

In this talk I will present several reasons why we love to use classes to organise our tests, and to share fixtures. Using class based tests allows you to be more explicit, in what fixtures are available to a set of tests, and allows sharing fixtures between tests not in the same folder. Using classes enables using fixture scope to greatly speed up your tests, while keeping the fixture namespace clear. And finally, using test classes allows you to do interesting things with inheritance and parametrisation, which would be a pain to do with functions only.

What do you need to know to enjoy this talk

Python level

Medium knowledge: You use frameworks and third-party libraries.

About the topic

You used or did it just a few times.

Mikuláš Poul

I've been coding in Python professionally for almost ten years, mostly working with Django, but have also written many Python-only libraries and applications. On all the projects I work and have worked on, testing is a strong focus, between owning the CI, speeding up tests and developing testing tools to make life easier.

Especially lately I've been focusing on reshaping the tests we write at Xelix to make them more maintainable and easier to write, and faster to run. This has lead to me writing private documentation, and writing a couple of pytest plugins, both private and public. The public ones include: detecting unused fixtures (, and analysing worker usage when running xdist (

At both of my current and past places of work, I've endeavoured to use Django and Django libraries to best suite the business needs, which meant a lot of experimenting, especially with functionality that Postgres provides, like schemas and materialized views. I maintain an internal fork of django-tenants that allows us to use it without subdomains, and maintain a library for managing Postgres views and materialized views from Django. (

Saturday 16 September

10:20 __main__

The Library and the Maze

Karel Minařík
streamed to other rooms


11:10 __main__


11:50 __floor__

Panelová diskuze: mýty a stereotypy o IT

Mia Bajić, Honza Javorek, Lucie Tvrdíková, Šárka Melicharová & Roman Hraška
Beginner’s track only in Czech
11:50 __init__