[TIP] A rare philosophical thought

C. Titus Brown ctb at msu.edu
Fri Aug 1 10:28:54 PDT 2008

So, I just posted a reply to someone new (or returning) to Python,


and one of his complaints was this:

The Python gurus recommend unit testing to make sure code is solid.
That's great. If I wanted to write dozens of lines of boilerplate
code in order to make sure stuff worked, I'd have stuck with C++. I want
to write less code and be confident in the belief that that code is
correct and error free.

My response was this:

Your take on unit testing seems just plain wrong. I know of no useful
language that can prevent the majority of programming errors without
some form of actually running the code, a.k.a. "testing". You might
think YMMV, but you're almost certainly wrong.

For some reason, this was the first time I'd really thought of things
this way: "testing" is really just "running the code", under actual or
likely-to-be actual circumstances.  The quality of your test effort can
be measured by how reflective it is of the actual circumstances under
which the code will be used, and the cost of the mismatches.


C. Titus Brown, ctb at msu.edu

More information about the testing-in-python mailing list