Offline

Leverage pytest's Fixture to write focused and highly decoupled tests

Track:
Testing, Quality Assurance, Security
Type:
Talk
Level:
beginner
Room:
S3A
Start:
14:30 on Thursday, 16 July 2026
End:
15:00 on Thursday, 16 July 2026
Duration:
30 minutes

Abstract

Everyone knows that tests are important, but not many people like writing them. That doesn’t happen because they don’t consider tests worth the time, but because writing them looks boring, repetitive, and, somehow, sometimes the test suite suddenly becomes a burden to maintain.

A common situation is:

  • You edit one line of code, and the whole test suite no longer works.
  • When you open the first test, you have absolutely no idea what it is supposed to test.
  • 80% of the test’s lines are not about the test.
  • The remaining 20% of the lines are scattered throughout the other 80% of the lines.
  • You manage to fix it, but it has been frustrating.
  • You open another test, same situation, and maybe the same fix is needed.
  • Frustration goes up.
  • Writing tests have become annoying...

Since writing tests can’t (and shouldn’t!) be avoided, let’s try to improve the way both single tests and the whole test suite are written.

With this talk, thanks to both paradigms and pytest’s Fixtures, you will learn to:

  • Reduce coupling with the codebase.
  • Keep each test focused on what it needs to test.
  • Avoid code duplication among tests.
  • Improve tests’ setup and teardown.