[TIP] Learning testing and TDD: unittest or PyTest or ?

Matěj Cepl mcepl at cepl.eu
Sun Sep 25 14:00:42 PDT 2016

On 2016-09-25, 13:11 GMT, Florian Bruhin wrote:
> I'd recommend to go with pytest - as you already discovered, 
> it has much useful functionality built-in, and is much more 
> DRY (and requires less boilerplate) than unittest.py does.

Of course, a maintainer of pytest would see things in this way.  
Just to add on the opposite side my experience with rewriting 
rather large QA tests from pytest to the standard unittest.  
Aside from our strong prejudice in favor of using just standard 
library, there is my problem with py.test fixtures. They seem to 
have some similar qualities to Perl ... they could be very very 
mighty servant, but they could be also a very dangerous master.  
The author of those tests fallen in love so much with py.test 
fixtures, that he created completely undebuggable mess, with 
variables jumping seemingly out of nowhere. Instead of 
deciphering all that monstrosity, it was just more simple to 
port all those tests to unittests, and the result is a way more 
simple and readable. That is not completely fault of py.test, 
the code was really horrible, but I would strongly warn py.test 
users before falling completely head over the heels for the 
fixture feature.


https://matej.ceplovi.cz/blog/, Jabber: mcepl at ceplovi.cz
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8
Las cosas claras y el chocolate espeso.
(Ideas should be clear and chocolate thick.)
    -- Spanish proverb

More information about the testing-in-python mailing list