Art of Unit Testing

Christoph Zwerschke cito at online.de
Wed Aug 3 04:19:05 EDT 2005


rafi wrote:
> 'should' may be too strong, 'may' may be better. In the meantime I found:
>     http://python-mock.sourceforge.net/

Thanks for the link. Björn also pointed to http://pmock.sourceforge.net

Using mock objects sounds like a good idea.

A problem with mock objects may be that they make writing tests for the 
occasional programmer yet another bit more difficult, and that you 
always have to ensure your mock objects really mock the real objects 
perfectly, so you have to write another test for that. The behavior and 
the API of the real objects may change every now and then.

Let me summarize some good answers in this thread:

- unittest is deliberately intended to be a JUnit implementation
- unittest is for *unit* testing (only) ;-)
- use mock objects to mimic the behaviour of external components like 
databases
- other more pythonic testing frameworks are out there

I think it would be good to have these remarks added to the unittest 
documentation in the Python library reference.

Also, if one of the more pythonic unit testing modules will be mature 
enough and widely accepted, I think it would be good to make it Python's 
standard (lib) testing framework and rename the current unittest back to 
pyunit or punit.

-- Christoph



More information about the Python-list mailing list