[Python-ideas] Please consider adding context manager versions of setUp/tearDown to unittest.TestCase
Chris Barker
chris.barker at noaa.gov
Tue Aug 22 20:19:33 EDT 2017
Getting kind of OT, but:
... pytest is too "magical" for you,
>
I do get confused a bit sometimes, but for the most part, I simple don't
use the magic -- pytest does a great job of making the simple things simple.
what do you use? Many Python testing tools like nose are just test
> *runners*, so you still need something else.
>
nose did provide a number of utilities to make testing friendly, but it is
apparently dead, and AFAICT, nose2, is mostly a test runner for unittest2
:-(
I converted to pytest a while back mostly inspired by it's wonderful
reporting of the details of test failures.
If your only complaint about unittest is that
> you_miss_writing_underscores_between_all_the_words, then unittest must
> be pretty good.
For my part, I kinda liked StudlyCaps before I drank the pep8 kool-aid.
What I dislike about unitest is that it is a pile of almost completely
worthless boilerplate that you have to write.
what the heck are all those assertThis methods for? I always thought they
were ridiculous, but then I went in to write a new one (for math.isclose(),
which was rejected, and one of these days I may add it to assertAlmostEqual
... and assertNotAlmostEqual ! ) -- low and behold, the entire purpose of
the assert methods is to create a nice message when the test fails. really!
This in a dynamic language with wonderful introspection capabilities.
So that's most of the code in unitest -- completely worthless boilerplate
that just makes you have to type more.
Then there is the fixture stuff -- not too bad, but still a lot klunkier
than pytest fixtures.
And no parameterized testing -- that's a killer feature (that nose provided
as well)
anyway, that's enough ranting.....
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170822/62bd74e3/attachment-0001.html>
More information about the Python-ideas
mailing list