Art of Unit Testing

Christoph Zwerschke cito at
Wed Aug 3 03:35:08 EDT 2005

Benjamin Niemann wrote:
> The unittest module is a 'port' of the JUnit framework for Java which has a
> certain wellknown API and semantics. The same API is available for many
> other languages, so it is probably a good idea to stick with it in order to
> make people coming from other language feel more comfortable with Python.

Ok, that's a good reason. I just had a look at the JUnit homepage. It 
seems like unittest has only implemented a part of JUnit. But you're 
right, even JUnit lacks setUpOnce and tearDownOnce. I found the 
following excuse and workaround in the JUnit FAQ:

> Some (many?) people don't like the unittest module, because it is not very
> pythonic - nothing to wonder as it has its root in the Java world. That's
> probably one of the reasons why there are other (more pythonic) unittesting
> frameworks for Python out there.

So I think it would have been better that "unittest" had been named 
"PUnit" to make clear that it is a JUnit port and to allow a more 
pythonic testing framework to be added to the Python's standard lib.

> I prefer to use unittest (because this was the API the textbook was using
> that introduced me to this topic) and I also had the problem of heavy setup
> costs. I deal with it by using a script around my testsuite (instead of
> calling just unittest.main()) that does the setup/teardown of the
> environment.

Yes, I think that's the simplest solution.

-- Christoph

More information about the Python-list mailing list