PyCon UK 2019

How to write readable tests
2019-09-13, 17:00–17:30, Ferrier Hall

So often, our tests are much harder to understand than the rest of our code. This is a shame! Find out how to write tests that act as living documentation from which you can gain deeper understanding of your system.


Have you ever found yourself scratching your head when reading an automated test? Even if we take pride in our application code, it’s all too easy for us to neglect readability in our tests.

But tests can be more than just a safety net that nobody reads unless they break. In this talk, I’ll show you how to write Python tests that you will love, and keep coming back to.

Topics will include:

  • Showing what matters and hiding the rest
  • Don’t Repeat Yourself in tests, too
  • Using custom dataclasses
  • Arrange, Act, Assert
  • Telling a story
  • Showing your working
  • Sentinels

Is your proposal suitable for beginners? – False