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

Florian Bruhin me at the-compiler.org
Sun Sep 25 06:11:16 PDT 2016


Hi,

(full disclosure: I'm one of pytest's core maintainers, but I'd have
told you the same even before I became one :P)

* boB Stepp <robertvstepp at gmail.com> [2016-09-24 10:53:27 -0500]:
> I have thought about PyTest off and on and actually had installed it
> earlier this week to play around with it.  It does seem much more
> intuitive and straightforward than unittest.  OTOH, I don't want to go
> an "easy" route and miss out on useful learning opportunities if that
> is what unittest will provide me.  But I have been striving while
> learning to respect and implement DRY principles and I really don't
> want to write repetitive test code, which essentially does exactly the
> same thing, just with different inputs.  And I can see myself wanting
> to exercise tests with a variety of test data, perhaps stored in
> file(s) for any substantial project I envision.  So if I continue in
> unittest-land I would have to adopt Ben's suggestion.
> 
> So, for now, my emphasis is on "learning".  I am currently trying to
> learn multiple things:  Python in general, OOP, TDD, CSc concepts,
> using Vim, Git, and any other needed software with their details of
> use to support these stated learning objectives.  In light of this,
> what would you advise?

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.

It also seems to me that more and more projects are starting to use
pytest, or switching from unittest/nose to pytest. For me, switching
to pytest and starting to use coverage.py is what motivated me to
actually write tests for a lot of previously untested code.

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20160925/88f0fdf0/attachment.pgp>


More information about the testing-in-python mailing list