Nose supports test generators. But the documentation says:
Please note that method generators are not supported in unittest.TestCase subclasses
This means all my test generators must be outside of unittest
framework.
Question: should I still use the unittest
framework for those tests where I can? Or should I, for consistency reasons, abandon unittest
entirely?
And why doesn't nose
support test generators within unittest.TestCase
? It seems to destroy the biggest advantage of nose
: that it is an extension rather than a replacement for unittest
, thus offering additional benefits without taking away any of the features provided by unittest
. Or am I missing something?
And a related question. If I ditch unittest
entirely, should I put my tests into global functions or into some new class hierarchy?
In nose, the lack of support for funkier kinds of tests in unittest.TestCases is intentional -- the idea was that nose should collect test from unittest.TestCases exactly as unittest does. Probably that was a bad idea, but it's very unlikely to change now.
So as long as you don't mind being a bit out on the bleeding edge, I'd suggest trying nose2. nose2 doesn't discriminate and supports all kinds of test plugins for all kinds of tests. Docs are on rtd: http://nose2.readthedocs.org/en/latest/index.html, downloads on pypi: http://pypi.python.org/pypi/nose2/0.4.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With