About me

Blog Posts Blog Tags Blog Feed

2023 2022 2021 2020 2019 2018 2017

Log in

Copyright © 2022
Jeffrey Elkner

Obey the Testing Goat - Part I

Testing Goat

Test-Driven Development with Python is a trainer on the discipline of of TDD using the Python web framework, Django, for the example project used to teach the discipline.

It aligns so well with what I am teaching my first year computer science students this year, that we just began using it in class. I had started going through it for the first time back over the Winter break, where I made it to Chapter 9: Testing Deployment Using a Staging Site. I will need to adapt our classroom environment to make this work, including setting up our own in-class DNS server using dnsmasq and using a KVM server to provide each student with their own Nginx server in our lab.

At a rate of one chapter each time the class meets, we will reach chapter 9 in mid March, so I have a bit of time to get the needed infrastructure working. In the mean time, I started the book over to better understand it, and today I will start it over again for a third time to keep pace with the students.

Setting Up the Development Environment

We will be hosting our Git respositories on GitLab, so the process that follows assumes that, as well as either Ubuntu 18.04 or Debian 10 as the platform.

To each of the following to create the Python virtual environment and install the needed software:

  1. Make a directory that will host the project, change into it, and create and then activate the virtual environment. I will use python-tdd-book this time to distinguish this as my third pass at this:

    $ mkdir python-tdd-book
    $ cd python-tdd-book
    $ python3 -m venv virtualenv
    $ source virtualenv/bin/activate
    (virtualenv) $
  2. Install the Selenium driver for Firefox, Gecko Driver, from We are going to put it in our virtual environment's bin subdirectory (virtualenv/bin), since students won't have access to administrative privileges. Assuming we still have the virtual environment activated, and that downloading Gecko put it in the user's Downloads directory, we will:

    (virtualenv) $ mv ~/Downloads/geckodriver-v0.24.0-linux64.tar.gz .
    (virtualenv) $ tar xzvf geckodriver-v0.24.0-linux64.tar.gz
    (virtualenv) $ rm geckodriver-v0.24.0-linux64.tar.gz
    (virtualenv) $ mv geckodriver virtualenv/bin/
    (virtualenv) $ geckodriver --version
    geckodriver 0.24.0 ( 2019-01-28)
    The source code of this program is available from
    testing/geckodriver in
    This program is subject to the terms of the Mozilla Public License 2.0.
    You can obtain a copy of the license at
    (virtualenv) $
  3. Finally, install the versions of Django and Selenium we will be using with the text:

    (virtualenv) $ pip install "django<1.12" "selenium<4"

That's it. We are ready to start TDD!

Setting Up the GitLab Repository

Since I am mainly writing this post as a resource for my students, I'll now provide assistance getting our GitLab repos setup. I am assuming we have followed all instructions in Chapter 1: Getting Django Set Up Using a Functional Test up to and including the commit of the .gitignore file. What follows will create a project on GitLab:

(virtualenv) $ git commit -m "Make initial commit"

*** Please tell me who you are.


  git config --global ""
  git config --global "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

(virtualenv) $ git config --global ""
(virtualenv) $ git config --global "Jose Ejemplo"
(virutalenv) $ git commit -m "Make initial commit"
[master (root-commit) fabfdef] Make initial commit
 7 files changed, 190 insertions(+)
 create mode 100644 .gitignore
 create mode 100644
 create mode 100755
 create mode 100644 superlists/
 create mode 100644 superlists/
 create mode 100644 superlists/
 create mode 100644 superlists/
(virutalenv) $

You will of course have to substitute your real name and email for the example ones. Assuming you already have your ssh key on GitLab, you can use Push to create a new project to guide you through creating your repo:

(virutalenv) $ git push --set-upstream master

Again, you will need to substitute your actual GitLab user name for jejemplo. So there we have it. I hope this post will help my students over some of the rough spots in the process.

Time to start testing!