[Tutor] Python&Pytest
Laura Creighton
lac at openend.se
Sat Jun 13 01:04:26 CEST 2015
In a message of Fri, 12 Jun 2015 17:51:55 -0400, Michelle Meiduo Wu writes:
>Yes, I also found Py.test is a good testing framework for automation testing.
>Another one is Robot testing framework. It's also a testing framework based on Python Unittest framework.
>Hard to pick one to use:)
pytest (formerly py.test) came out of the pypy project. We needed
something rather more complicated to test our python code given that
we could not 'make a new pypy' every time we needed to run our tests.
(That took hours). So we built this thing. However, Michael Foord
ported a whole lot of what we needed (but the standard python
unittest module didn't have) back into unittest. And these days
lots of pytest has been rewritten enough times that I am no longer
familiar with the code. But at the time we needed to write oejskit,
py.test was the place to do it, in part because if we needed any
changes to py.test to accomodate what we wanted, we could just
sit down and write that too. Getting changes into something that
is in the python standard library is a lot harder -- the political
process is often orders of magnitude harder than just having working
code. But py.test was a much more swiftly changing codebase at
that time, and hardly anybody used it, and if we changed things so
that their tests broke, they mostly were also benefitting from the
new functionality -- and you don't develop on the bleeding edge
if you aren't in some way excited by such changes ...
These days, pytest is very stable, doesn't change much, and has
tons of satisfied users who would be very, very, very upset if we
upset their applecarts. So that doesn't happen. But it makes
decisions like yours harder. I personally find unittest to be
so verbose that it makes writing tests unpleasant. But other people
do not share my dislike of verboseness, so my advice, again, is to
try both for a week. And then see how you feel about it.
Note that if you decide you like pytest, it comes with a script that
I wrote to convert standard library unittests to pytest tests, so
you won't waste that work. I don't know of any scripts that go
the other way, but they may exist.
best of luck,
Laura
More information about the Tutor
mailing list