Thanks background from vecteezy

Getting Started TDD in 30 Seconds with Python

Quick start to setup python script for Test Driven Development in 30 seconds

Time start!

sudo pip install pipenv

2. create a directory and enter to it

mkdir my-tdd
cd my-tdd

3. Activate Python virtual environment, then the tool will automatically create it (if it’s not exist!)

pipenv shell

4. Install pytest as a dev dependency

pipenv install pytest --dev

5. create file and test file in any place of the directory

# in lib.pydef hello():
return "hello"
# in or test_lib.pyimport lib
def test_hello():
assert lib.hello() == "hello"

6. let’s test


Getting result!

The structure will be like this


You can use automatically test your code when the code's changed using pytest-watch

pipenv install pytest-watch

Let’s fun with TDD


Time stoppppppppppp!

As I said before, this blog will end within 30 seconds

Thanks guy, any question, pls comment

Good bye, see you

P.S. fastest blogging ever 🙏

Originally published at



Software Engineer, using ASP.NET Core, React, TypeScript. Blog at

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store