Test-Driven Development with Python

Errata for Test-Driven Development with Python

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
PDF
Page x
1st paragraph under heading "Contacting O'Reilly"

Text found was: If you’d like to get in touch with my beloved publisher with any questions about concerning this book, contact details follow: I think it should be: If you’d like to get in touch with my beloved publisher with any questions about this book, contact details follow:

Jeff Orr  Mar 29, 2013  May 08, 2013
PDF
Page Cover
size

The cover is sized approximately 29" x 38" which makes it more difficult to use. When telling the reader to fit to width, it bases the magnification on this one oversize page's width, leaving the real pages far too small to read.

Note from the Author or Editor:
I believe this has been fixed.

Galeran  Apr 03, 2013  May 08, 2013
Other Digital Version
nil
Chapter 5 / Section Saving the POST to the database / Beginning of a paragraph

Missing word (possibly "ignore") in the following sentence: Remember, I’m not saying you should always glaring problems like this in "real life".

Note from the Author or Editor:
fixed in latest draft.

Anonymous  Apr 10, 2014 
Other Digital Version
nil
Chapter 6

Section: Implementing the new design using TDD Last comment in the code box following "Delete everything from the comments just before the self.fail..." The first word contains a typo: # Satisified, they both go back to sleep

Note from the Author or Editor:
fixed in latest draft

Anonymous  Apr 11, 2014 
Other Digital Version

[Site] http://chimera.labs.oreilly.com/books/1234000000754/pr01.html#_conventions_used_in_this_book [Error] > Constant width italic > Shows text that should be replaced with user-supplied values or by values determined by > context. The CSS font style of the first line of the quotes above isn't italic, it displays using a regular font style. This seems caused by (from the page source): > <em><code class="literal">Constant width italic</code></em> and from the CSS of $('code.literal'): > font-style: normal; seems to be the cause.

Note from the Author or Editor:
this is presumably a deficiency in the chimera formatting? tbh i don't use constant width italic at all in the book, so we could just drop the whole quote

Stephen W  May 17, 2014  Jun 09, 2014
Other Digital Version
online
Chapter 10, Section "Refactor: Transferring the new_item Functionality into view_list"

It is written: "Let’s take all the old tests from NewItemTest, the ones that are about saving POST requests to existing lists, and move them into ListViewTest. As we do so, we also make them point at the base list URL, instead of …/new_item:" I believe it's mistake and the author means "/add_item" which is the word being used both urls.py and test_views.py. Example, in urls.py: url(r'^(\d+)/add_item$', 'lists.views.add_item', name='add_item'),

Note from the Author or Editor:
am fixing this.

Ze Santos  Jun 26, 2014 
PDF
Page 1
2nd paragraph

Sentence as is: Now, normally first step in web development is getting your web framework installed and configured. I think it should include the word "the": Now, normally the first step in web development is getting your web framework installed and configured.

Jeff Orr  Mar 29, 2013  May 08, 2013
PDF
Page 3
code block after 2nd paragraph

In the code block I see: browser.get('http://localhost:8000') On page 4, there is this sentence in the first paragraph: You should see a browser window pop up, try and open up localhost:8001, and then the Python error message. Either the code block should be modified to reference port 8001, or the sentence should be modified to reference port 8000. These are not consistent.

Jeff Orr  Mar 29, 2013  May 08, 2013
PDF
Page 4
In tip/suggestion/note

Spelling error and no punctuation at end of sentence: If you see an ImportError, or it looks like selenium if failing to open Firefox, you should go back and take another look at the pre-requisites Should be: If you see an ImportError, or it looks like selenium is failing to open Firefox, you should go back and take another look at the pre-requisites.

Jeff Orr  Mar 29, 2013  May 08, 2013
PDF
Page 5
United Kingdom

Just a suggestion. You mention an 'app', and most of the command line stuff is from some baseline directory? I was concerned that I was issuing commands from the wrong directory until I realised they were all from the same directory? More difficult since there are two 'superlist' directories? perhaps suggest a working directory, then for your command line input 'show' the directory app> ...... cmd One other, PDF page 34 self.assertTrue(response.content.strip().endswith('</html>')) Not needed on my Linux box (just fyi) the preceding example works fine. Good luck.

Dave Pawson  Apr 03, 2013  May 08, 2013
PDF
Page 9
Bottom, after last 'git status' command

git status results should indicate that .gitignore has been modified: On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: .gitignore new file: functional_test.py new file: manage.py new file: superlists/__init__.py new file: superlists/settings.py new file: superlists/urls.py new file: superlists/wsgi.py Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: .gitignore

Note from the Author or Editor:
Well spotted! And very frustrating, my tests should have picked this up. turns out they weren't testing what I though they were, classic mistake. I will fix it for the next edition.

Shafique Jamal  Jun 11, 2014 
PDF
Page 11
2nd sentence

The following comment line reads: # that the site has generate a unique URL for her -- there is some It should be: # that the site has generated a unique URL for her -- there is some

Jeff Orr  Mar 30, 2013  May 08, 2013
PDF
Page 12
3rd paragraph, 2nd sentence

extra space in compound adjective after hyphen: ready- made should be: ready-made

Jeff Orr  Mar 30, 2013  May 08, 2013
PDF
Page 12
functional_tests.py code example

The code sample is missing the concluding: if __name__ == '__main__': unittest.main() ... which is mentioned in the 5th bullet point immediately afterwards. Without it, the test simply returns with no output to the command line. Cheers, Mike

Michael Allan  Apr 03, 2013  May 08, 2013
PDF
Page 12
last paragraph

Words in the Constant width font span multiple lines. Examples include: last paragraph on line 12: test_can_start_a_list_and_retrieve_it_later second paragraph on page 13: unittest and assertEqual

Note from the Author or Editor:
to be fixed in production?

James O'Donnell  Apr 03, 2013  Jun 09, 2014
PDF
Page 13
2nd paragraph, 2nd sentence

Sentence starts: uni ttest provides lots helper functions like this to make test assertions, Should have word 'of': uni ttest provides lots of helper functions like this to make test assertions,

Jeff Orr  Mar 30, 2013  May 08, 2013
PDF
Page 13
3rd paragraph

The third paragraph references code that is not in the code example on page 12. if __name__ == '__main__' clause and unittest.main() are not found on page 12 in the code.

Jeff Orr  Mar 30, 2013  May 08, 2013
PDF
Page 13
3rd bullet point

The text describes the "if __name__ == '__main__' clause" in this bullet point. Nowhere can I find in the code given previously that this clause is used. Not including this clause somewhere in the code will cause it to not run properly and not give the result from your example in the book.

SoonerBourne  Apr 08, 2013  May 08, 2013
PDF
Page 13
Top of page

The block of code: if __name__ == '__main__': unittest.main() ...appears on the following page from the proceeding class declaration and because they are separated the indentation level is lost and it is easy to include it in the class declaration (which causes the test to never run). I recommend you keep all the code on one page.

Note from the Author or Editor:
to be fixed when book goes to production?

Andrea Costantini  Jun 19, 2013  Jun 09, 2014
PDF
Page 15
Tip copy

"dev. server" should be "dev server"

James O'Donnell  Apr 03, 2013  May 08, 2013
PDF
Page 15
Next to symbols 2 and 3

The sentence currently reads, "setUp and tearDown special methods..." It should be updated to, "setUp and tearDown are special methods..."

Note from the Author or Editor:
fixed in latest draft

Ramces Chirino  May 27, 2014 
PDF
Page 16
bullet 2

"or at least to get past its current failure" should be "or at least to get passed its current failure"

James O'Donnell  Apr 03, 2013  May 08, 2013
PDF
Page 17
3rd paragraph, 1st sentence

Sentence reads: Does that may seem slightly redundant? I think it should read: Does that seem slightly redundant?

Jeff Orr  Mar 31, 2013  May 08, 2013
PDF
Page 18
2nd paragraph, 3rd sentence

The sentence reads: Well, a test failure means we’re allowed to change production code, so let’s open up the mysite/settings.py file. I think the file settings.py should be in the folder superlists: Well, a test failure means we’re allowed to change production code, so let’s open up the superlists/settings.py file.

Jeff Orr  Mar 31, 2013  May 08, 2013
PDF
Page 20
3rd paragraph

Should the following be listed as command prompts? *git status* # should show you superlists/settings.py has changed and lists/ is untracked *git add superlists/settings.py* *git add lists* *git diff --staged* # will show you the diff that you're about to commit *git commit -m"Add app for lists, with deliberately failing unit test"* # I'll let you guess what commit -m does! Instead: $ git status # should show you superlists/settings.py has changed and lists/ is untracked $ git add superlists/settings.py $ git add lists $ git diff --staged # will show you the diff that you're about to commit $ git commit -m"Add app for lists, with deliberately failing unit test" # I'll let you guess what commit -m does!

Jeff Orr  Mar 31, 2013  May 08, 2013
PDF
Page 21
1st paragraph

Sentence reads: So we want to test two thing: 'thing' needs to be plural: So we want to test two things:

Jeff Orr  Mar 31, 2013  May 08, 2013
PDF
Page 22
1st paragraph, second sentence

Sentence starting with: Well, bewarned: should be: Well, be warned:

Jeff Orr  Mar 31, 2013  May 08, 2013
PDF
Page 24
5th paragraph

Should the following be in asterisks?: *git diff* # should show changes to urls.py, tests.py, and views.py *git commit -am"First unit test and url mapping, dummy view"* Should it be: $ git diff # should show changes to urls.py, tests.py, and views.py $ git commit -am"First unit test and url mapping, dummy view"

Jeff Orr  Mar 31, 2013  May 08, 2013
PDF
Page 33
2nd to last sentence

Sentence reads: There are lots of Python templating frameworks out there, and Django has its own which work very well. 'work' should be plural: There are lots of Python templating frameworks out there, and Django has its own, which works very well.

Jeff Orr  Mar 31, 2013  May 08, 2013
PDF
Page 33
In the middle of the page, first paragraph after heading The “Don’t test constants” rule, and templates to the rescue

In bold, there is "Don’t test contants", and it should be constants...

Marek Turnovec  Apr 04, 2013  May 08, 2013
PDF
Page 33
last code block

assert wibble = 3 is a SyntaxError. It should be assert wibble == 3

James O'Donnell  Apr 06, 2013  May 08, 2013
PDF
Page 62
The figure

The figure is not of the error, but of the working application.

Note from the Author or Editor:
Hi there, thanks for submitting this erratum. I've fixed it in the latest release of the book. Please don't hesitate to send any other comments, feedback or suggestions! obeythetestinggoat@gmail.com

Ramon Maria Gallart  Jan 30, 2014  Jun 09, 2014
PDF
Page 74
1st paragraph

The paragraph states: ".. as well as a new file, db.sqlite3. Let’s add the first three, and then add the database to our .gitignore:" But db.sqlite3 is already added to .gitignore (on page 8).

Note from the Author or Editor:
fixed in my latest draft

Fredrik Larsson  May 18, 2014  Jun 09, 2014
ePub
Page 113
Just prior to header "What we skipped over...."

I found moving the left margin by a fixed amount (-10px) didn't necessarily yield a pass. My window was slightly smaller, and thus I had to reduce it by -15px to pass. This leads me to believe that the results of the test vary according to computer, which is not very robust. It seems to me that making the delta in "assertAlmostEqual" a fraction of the screen width as opposed to a fixed amount might be a more flexible solution (though this is only my opinion).

Note from the Author or Editor:
fixed in latest versions

Sean Robertson  Aug 29, 2013  Jun 09, 2014
Mobi
Page 198
United States

functional_test.py reads: browser - webdriver.Firefox() s/b browser = webdriver.Firefox()

john brasher  Apr 27, 2013  May 08, 2013
ePub
Page 266
listing on bottom of page

The following code does not work with Django 1.6: def validate_unique(self): try: self.instance.validate_unique() except ValidationError: self._update_errors({'text': [DUPLICATE_ITEM_ERROR]}) The _update_errors() method expects an error with an 'error_dict' attribute and not the dict itself. The base method in django.forms.BaseModelForm passes the ValidationError instance itself to _update_errors(). Therefore the following fix is working: def validate_unique(self): try: self.instance.validate_unique() except ValidationError as e: e.error_dict = {'text': [DUPLICATE_ITEM_ERROR]} self._update_errors(e)

Note from the Author or Editor:
to be fixed as part of upgrade to 1.6

Anonymous  Nov 11, 2013  Jun 09, 2014
PDF
Page 294
listing

The showed template snipped should be in lists/templates/base.html instead of lists/templates/home.html.

Note from the Author or Editor:
fixed in latest draft

Jan Dittberner  Apr 20, 2014  Jun 09, 2014
PDF
Page 295
first two listings

The first listing should be in lists/templates/base.html instead of lists/templates/home.html. The test should go into lists/tests/test_views.py instead of lists/test_views.py that does not exist if you follow the guideline in previous chapters.

Note from the Author or Editor:
fixed in latest draft

Jan Dittberner  Apr 20, 2014  Jun 09, 2014
PDF
Page 296
last paragraph and subsequent listings (including those on next page)

just adding {% block %} tags around a template block does not make it necessary to use {% block ... %}{{ block.super }}{% endblock %} in derived templates, instead it is necessary to define an empty block in derived templates that do not need the block.

Note from the Author or Editor:
fixed in latest draft

Jan Dittberner  Apr 20, 2014  Jun 09, 2014
PDF
Page 298
listing at the end of page

the listing should be for file lists/tests/test_views.py instead of lists/tests.py

Jan Dittberner  Apr 20, 2014  Jun 09, 2014
PDF
Page 414
2nd paragraph

"We can see they’re both happening in the generiv view's..." Change "generiv" to "generic".

Note from the Author or Editor:
fixed in latest draft

Anonymous  May 05, 2014 
ePub
Page 1162
index

Spelling error in index "Fuctional Core" in the "F" section in the index.

Note from the Author or Editor:
quite right, i'll fix it...

John Antolak  Jun 20, 2014