Skip to main content

Obey the Testing Goat! TDD for Web Development with Python

Harry Percival (PythonAnywhere)
JavaScript - HTML5 - Web | Python | Tools & Techniques
Portland 252
Tutorial Please note: to attend, your registration must include Tutorials.
Average rating: ****.
(4.19, 16 ratings)

THIS TUTORIAL HAS REQUIREMENTS AND INSTRUCTIONS LISTED BELOW

The aim is to cover the basics of setting up a simple database-driven site using Python and Django, but using full, rigorous TDD at every step along the way.

We’ll learn how to set up functional tests with Selenium, how to set up Django, how to run Django unit tests, how TDD actually works in practice, the unit test / code cycle where we re-run the tests after each tiny, incremental change to the code, as well as all the basics of Django’s models, views and templates. We’ll talk about what to test, what not to test, what the point of all this testing is anyway, and I promise to make it all at least moderately entertaining.
Plus it’s all in Python 3!

TUTORIAL REQUIREMENTS AND INSTRUCTIONS FOR ATTENDEES

Pre-requisites:

* Python 3.3+
* Git
* Firefox
* Selenium
* Django 1.7 (from https://github.com/django/django/archive/stable/1.7.×.zip)

There are detailed instructions for Windows, Mac and Linux on how to install things here:
http://chimera.labs.oreilly.com/books/1234000000754/pr02.html#_required_software_installations

* Attendees wishing to follow up on the session can find an entire book’s worth of TDD materials, available for free, at www.obeythetestinggoat.com

QUESTIONS for the speaker?: Use the “Leave a Comment or Question” section at the bottom to address them.

Harry Percival

PythonAnywhere

During his childhood Harry seemed to be doing everything right — learning to program BASIC on Thomson TO-7s (whose rubber keys went “boop” when you pressed them) and Logo on a Green-screen Amstrad PCW. Something went wrong as he grew up, and Harry wasted several years studying Economics, becoming a management consultant (shudder), and programming little aside from overcomplicated Excel spreadsheets.

But in 2009 Harry saw the light, let his true geek shine once again, did a new degree in Computer Science, and was lucky enough to secure an internship with Resolver Systems, the London-based company that has since morphed into PythonAnywhere. Here he was inculcated into the cult of Extreme Programming (XP), and rigorous TDD. After much moaning and dragging of feet, he finally came to see the wisdom of the approach, and now spreads the gospel of TDD through beginner’s workshops, tutorials and talks, with all the passion of a recent convert.

Harry is currently writing a book for O’Reilly, provisionally titled “Test-Driven Development of Web Applications with Python”. He is trying to persuade his editor to have the title changed to “Obey the Testing Goat!”.

Comments on this page are now closed.

Comments

Tessa Broxton
08/22/2014 4:30am PDT

Great info really helpful and thx for the github link :)

Just found this hyper cool django 1.7 Tshirt for the Portland conference and gonna get my boyfriend to buy me it before they all go!

Anyone else going to Portland?

07/21/2014 4:51pm PDT

Thanks for the tip Doojin! And hey, for anyone listening, be sure to hit the “rate this session” button above, and please give as much feedback as you can — O’Reilly appreciate it to help plan future years, and I really appreciate it to help improve the tutorial, whether it’s positive or negative. Thanks everyone!

07/21/2014 4:11pm PDT

https://pypi.python.org/pypi/selenium/2.40.0

07/21/2014 4:08pm PDT

For MBP Retina, firefox may look tiny.
(https://code.google.com/p/selenium/issues/detail?id=7445)
install selenium 2.40.0 python webdriver
remove 2.42.1

Picture of Shirley  Bailes
07/16/2014 7:38am PDT

Earl – The URL www.obeythetestinggoat.com is working now. Thanks again for letting us know!

Picture of Shirley  Bailes
07/15/2014 11:40am PDT

Thanks Earl. We’ve reached out to Harry to get it corrected. Will post again once it is.

Picture of Earl Ruby
07/15/2014 11:31am PDT

http://www.obeythetestinggoat.com/ is showing the message “Unhandled exception” on the main index page:

https://www.dropbox.com/s/lbt300ync4p83gk/Screenshot%202014-07-15%2011.29.23.png