Skip to main content
EuroPythonCode of ConductLive 📹

TDD in Python with pytest

Wicklow Hall 2B
Start (Dublin time):
Start (your time):
180 minutes


This workshop will guide you step-by-step through the implementation of a very simple Python library following a strict TDD workflow. At the end of the workshop you will have grasped the main principles of TDD and learned the fundamentals of the Python testing library pytest.



Test-Driven Development (TDD) is fortunately one of the names that I can spot most frequently when people talk about methodologies. Unfortunately, many programmers still do not follow it, fearing that it will impose a further burden on the already difficult life of a developer.

TDD is a methodology, something that can help you to create better code. But it is not going to solve all your problems. As with all methodologies you have to pay attention not to commit blindly to it. Try to understand the reasons why certain practices are suggested by the methodology and you will also understand when and why you can or have to be flexible.

During the workshop we will learn what TDD is, and what are the main rules. We will do this developing a very simple Python library together in a sort of a game that mirrors a daily TDD development routine. While we do this, we will also learn how to use pytest, which is one of the most used testing libraries in Python. Oh, we will also learn when NOT to follow the rules!

Setup instructions:

  • Create and activate your Python virtual environment
  • git clone
  • cd simple_calculator
  • git checkout --track origin/develop
  • pip install -r requirements/dev.txt
  • You should be able to run pytest -svv and get an output like
================================ test session starts ===============================
platform linux -- Python XXXX, pytest-XXXX, py-XXXX, pluggy-XXXX --
cachedir: .cache
rootdir: cabook/code/calc, inifile: pytest.ini
plugins: cov-XXXX
collected 0 items 

=============================== no tests ran in 0.02s ==============================

The speaker

Leonardo Giordani

Born in 1977 together with Star Wars, bash, Apple ][, Dire Straits, The Silmarillion, and many other great things.

I started coding in April 1987 on a Sinclair ZX Spectrum. I then moved to MS-DOS PCs and in 1996 I started using Linux and became interested in operating system internals. I love software architectures, algorithms, mathematics and cryptography.

I’m mainly interested in open source software. I like both the theoretical and practical aspects of computer science.

I am currently working as a contractor DevOps and Python developer while I design a DevOps bootcamp that I will run in London from October 2022.

From 2013 I blog some technical thoughts at

In 2018 I published the free book “Clean Architectures in Python”

← Back to schedule