[TIP] how to test "impossible" events

Grig Gheorghiu grig at gheorghiu.net
Mon Sep 29 16:21:00 PDT 2008


--- On Mon, 9/29/08, Grig Gheorghiu <gheorghe_gheorghiu at yahoo.com> wrote:

> <dalke at dalkescientific.com> wrote:
> 
> > 
> > For examples, I check that the HTTP headers have the
> right
> > content-type, that the response body contains the
> expected
> > structure, that the number of fields in the response
> > matches
> > the number of fields I requested, etc.  
> 
> IMO this is overkill. The Web service that sends you data
> probably relies on lower-level libraries/modules that put
> together the HTTP responses. At this point, you're
> testing those low-level modules and not your code. A more
> interesting test is what happens at the higher-level, i.e.
> with the actual payload/data that your code receives. At
> that level you can write unit tests against corner cases and
> see how your code reacts to various abnormal data sets.

However, all this being said, here's a very cool Google AppEngine site that returns a specific HTTP response code so you can test your app in the presence of that response:

http://arthurkoziel.com/2008/09/29/the-http-response-with-specific-status-code-app/

Grig



More information about the testing-in-python mailing list