[TIP] how can I find in TestCase whether runs verbosely?
chris.jerdonek at gmail.com
Sun Feb 17 13:11:02 PST 2013
On Sun, Feb 17, 2013 at 11:47 AM, Matěj Cepl <mcepl at redhat.com> wrote:
> I would like to make my unittest testsuite to drop some intermediate
> test results when it is run with -v in the verbose mode. How can I find
> out in the TestCase object, that the run is verbose?
It doesn't seem like this information is available to TestCase by
default. Information related to the "verbosity" flag seems to wind up
in attributes of the TestResult object, but the current TestResult
object doesn't seem to be available to TestCase via the "public" API
(only via an internal _outcome attribute of the TestCase class).
The way I would do this is pass the verbosity information to your
TestCase class another way. You could store this information in a
global variable and have your TestCase access the information that
way. But my preference would be to add the verbosity information to a
custom TestLoader and pass whatever data you need to your TestCase
instances via the load_tests protocol.
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
More information about the testing-in-python