[TIP] A rare philosophical thought

Michael Foord fuzzyman at voidspace.org.uk
Sun Aug 3 08:37:11 PDT 2008


Noah Gift wrote:
>
>
>     I like it. The oft-cited 'boilerplate' is usually an import and a
>     class
>     definition...
>
>
> Compared to say doctest or nose, unittest feels like riding a 10 speed 
> made out of lead to me :)
>  

There's obviously quite an element of personal taste in this. The 
ConfigObj tests are all using doctest - and I abhor it for general unit 
testing. It is much more painful for a variety of reasons.

>
>     >> UNITTEST IS EVIL.
>     >>
>     >
>     >
>
>     I'm aware of no justification for that statement...
>
>
> Well, I think even Guido mentioned that he is generally unhappy with 
> some of the Java APIs that Python copied.  I am assuming unittest 
> falls into this category as well.
>
PEP-8'ification of method names would help, and perhaps simplifying some 
of the internal architecture.

> Additionally, I guess I personally have a problem with OO in general, 
> as I feel a lot of OO is boilerplate, but that is a totally separate 
> issue :) I do think there is some evil lurking in unittest because it 
> tempts some abstract the hell out it, and then all of a sudden you 
> have think deeply about how your test architecture is designed, and 
> completely forget that this is not even what you were trying to do in 
> the first place, which is simply test your code.
>

The OO architecture of unittest allows for some very nice abstractions - 
with custom testcases etc.

Our functional test framework has gradually become a testing DSL as 
we've managed to abstract away common testing patterns. For some of our 
tests we have one to one correspondence between lines in our user story 
and the code required to test it.

I guess if you dislike OO then a class based testing framework is not 
going to be ideal. :-)

>
>
>
>     > The many good points of the standard library unittest module have
>     > allowed me to write far better Python code than I would
>     otherwise have
>     > written. It's not evil in my view.
>     >
>     > It's ugly. It's crufty. It's not PEP-8-conformant. It's mostly
>     > unmaintained. It can lead to rather baroque unit test modules.
>     But it
>     > also has many good features, and I don't think any of the bad ones
>     > make it "evil".
>     >
>     >
>     >> UNITTEST NEEDS TO BE REPLACED.
>     >>
>     >
>     > Entirely agreed on this point. I think, though, that you'll find
>     > little immediate consensus on what to replace it with :-)
>     >
>     >
>
>     Personally I disagree - although there are obvious improvements
>     that can
>     be made.
>
>
> I would vote for something dirt simple like nose.

But in order to replicate the nice error reporting from assert failures, 
node has to do some very evil hackery under the hood. I doubt that would 
ever make it into the standard library, and without that hackery plain 
asserts would be unusable - which I guess is part of what you like about it.

Michael

>  
>  
>
>
>
>     Michael
>
>     --
>     http://www.ironpythoninaction.com/
>     http://www.voidspace.org.uk/
>     http://www.trypython.org/
>     http://www.ironpython.info/
>     http://www.theotherdelia.co.uk/
>     http://www.resolverhacks.net/
>
>
>     _______________________________________________
>     testing-in-python mailing list
>     testing-in-python at lists.idyll.org
>     <mailto:testing-in-python at lists.idyll.org>
>     http://lists.idyll.org/listinfo/testing-in-python
>
>
>
>
> -- 
> Noah Gift
> http://noahgift.com


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.theotherdelia.co.uk/
http://www.resolverhacks.net/




More information about the testing-in-python mailing list