TDD Practice: Time API with Django

submited by
Style Pass
2022-05-20 00:30:05

This is the blog post version of a workshop I ran at DjangoConEU in 2018. I’ve updated it for, and tested with, Django 4.0 but this is otherwise mostly unchanged...

Treat this like a Kata. Follow the steps below exactly the first time through, then practice by completing the task a second time by yourself.

When you do it by yourself you can delete the Django project and create a new one, or use a completely different language or web framework.

We're going to follow the Red -> Green -> Refactor practice of TDD in this example. This means that every line of code we write for our application will be written to make a failing test case pass. During each cycle we will:

When we're refactoring we can think about changes to both our production code and our test cases. You won't always need to refactor after making the test pass, but you should always take a moment to review what you've done.

This creates a new directory called venv containing our Python virtual environment. To activate the environment you need to source the activate script:

Leave a Comment