/documentations/python_libraries/testing/

Testing

Introduction

This document is a short introduction to two python testing modules:

Below some links to motivate the reader to look at this modules, which may appear less attractive then plotting modules or scientific libraries:

Today everyone knows about software bugs, what is less known is that the "first actual case of bug being found" was a moth.

The reader has probably spent enough time debugging the weekly exercises, to see the need for good tests. A web search of: "worst software bugs", shows that bugs can have serious consequences (see Wired or Wikipedia). To avoid such accidents and improve software quality in general, countless testing techniques have been developed: white-box testing, black-box testing, fuzz testing, fault injection, visual testing, grey-box testing, and many more (see Wikipedia). From a theoretical point of view one would rather prove the correctness of software then test it (see: Formal verification also interesting is Formal Proof). A well known quotation by Donald Knuth about this topic is:

Beware of bugs in the above code; I have only proved it correct, not tried it *

Another quotation by Donald Knuth about the right frame of mind when writing test code:

My test programs are intended to break the system, to push it to its extreme limits, to pile complication on complication, in ways that the system programmer never consciously anticipated. To prepare such test data, I get into the meanest, nastiest frame of mind that I can manage, and I write the cruelest code I can think of; then I turn around and embed that in even nastier constructions that are almost obscene. (Donald Knuth, The Errors of TEX, 1989)

Links