The Testing Goat

Obey the Testing Goat!

TDD for the Web, with Python, Selenium, Django, JavaScript and pals...

Latest release (the last big one?): Python 3.6, Django 1.11 beta

Mon 13 March 2017
By Harry

Hi all! A brief overview of changes in the latest version, with hopefully a few pointers for people half-way through the book and looking to adapt.

Python 3.6 and Django 1.11b: minimal changes, other than f-strings

The main feature in Python 3.6 that's made an impact (for the book and, arguably, elsewhere) is f-strings.

I have to say when I first heard of them I was pretty skeptical, they sounded a bit like YOLO-ing **locals() all over your code, scary, but those concerns have occurred to the brighter minds than mine that develop Python, and they figured there was nothing truly to be scared about, so I should relax.

I'll tell you what really made me relax, which was using them! I can't count the number of times I replaced a 3-line string.format() or an incoprehensible %s substitution with an f-string one-liner, and felt my code was nicer and more readable as a result.

The move to 3.6 also forced me to upgrade to Django 1.11 at the same time, since it's the only version of Django that officially supports Python 3.6, and that was pretty much entirely painless too. No major code changes as a result, and since it's going to be an LTS, I'm hoping I'll be able to stick with it for a long while over the lifetime of this 2e of the book.

Other minor improvements: fabric3

While I was at it I decided to upgrade to a Python 3 fork of fabric (thanks to all the readers who encouraged me to do so), and that saves us from a pretty awkward hop via subprocess to Python 2. Here's the old ascii-art diagram, preserved for posterity:

## Locally:

.create_pre_authenticated_session  →   .management.commands.create_session

## Against staging:

.create_pre_authenticated_session      .management.commands.create_session
.create_session_on_server                run create_session

     ↓                                                ↑
subprocess.check_output    →    fab   →   fabfile.create_session_on_server

the old, bad way of doing it

That's now much neater in the server-side debugging chapter. Huge thanks to the fabric3 developers.

What to do if you're half-way through the book

I'm always a fan of upgrading! Because the changes are all quite minor, you should be able to just:

  • Install Python 3.6 (downloadable on windows + macos, can use deadsnakes ppa on Ubuntu)

  • rmvirtualenv superlists

  • re-create the virtualenv with Python 3.6 (see the pre-reqs chapter for help, particularly on windows)

  • pip install django==1.11b1 selenium fabric3

What about Selenium 3?

If you actually started the book before Jan 30th or so, and you haven't made the upgrade to Selenium 3 yet, that's a bigger deal, and for that I'd recommend starting again at the beginning of the book. Don't worry, you'll zip through the chapters much quicker the second time, and it should really help bed in the learning.

What did I miss?

Honestly, it does feel like it was all a bit too easy. Is there anything I missed? Any new features from Python 3.6 or Django 1.11 that you think I should have included in the book? Let me know!

Thanks, as ever, for reading.


comments powered by Disqus
Read the book

The book is available both for free and for money. It's all about TDD and Web programming. Read it here!

Reviews & Testimonials

"Hands down the best teaching book I've ever read""Even the first 4 chapters were worth the money""Oh my gosh! This book is outstanding""The testing goat is my new friend"Read more...


A selection of links and videos about TDD, not necessarily all mine, eg this tutorial at PyCon 2013, how to motivate coworkers to write unit tests, thoughts on Django's test tools, London-style TDD and more.

Old TDD / Django Tutorial

This is my old TDD tutorial, which follows along with the official Django tutorial, but with full TDD. It badly needs updating. Read the book instead!

Save the Testing Goat Campaign

The campaign page, preserved for history, which led to the glorious presence of the Testing Goat on the front of the book.