Learning Test-Driven Development

Errata for Learning Test-Driven Development

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
Page 124
Source code

First off; Love your book! I've been doing TDD for 15+ years and remember reading Kent Beck's book back in 2005-ish and I love that you use the same code examples .

Anyway; I'm not reporting a typo/error per se, but more a little improvement. In the Python code handling errors you have a regex: "Missing exchange rate\(s\):\[USD\->Kalganid,EUR\->Kalganid,KRW\->Kalganid\]". If you add a "r" before the expression most code editors (for instance VS Code) will give you some syntax highlighting for the regular expression.

r"Missing exchange rate\(s\):\[USD\->Kalganid,EUR\->Kalganid,KRW\->Kalganid\]"

Note from the Author or Editor:
Thank you for submitting the suggestion for improvement on page 124.

The "r" character is one of the prefixes allowed by Python for regular expressions. It is not particular to any IDE (e.g., VS Code). It has to do with how Python treats regular expressions. The fact that IDEs may provide improved syntax highlighting -- although that, itself, is debatable on accessibility grounds -- is beside the point.

From the Python manual:

"Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and treat backslashes as literal characters."

Prefixing the regex expression with an r (or R) does not make any difference to the tests. It does require an additional explanation in the text somewhere -- perhaps as a TIP callout -- to clarify what that prefix means. There is some value to that.

I'll keep your suggestion in mind when the next set of changes is made to the book's manuscript.

Thank you, again, for reading and commenting on my book. I appreciate you for it.

Kjetil Klaussen  Jan 23, 2022