Can a test case tell if VERBOSE is used in pyunit test?

N

Noah

Is there a way for a test case method in a class derived
from unittest.TestCase to tell if the harness was started
with the verbose option? I would like my test cases to
print out a little extra information if the tests were run with
-v or -vv.

yours,
Noah
 
P

Peter Hansen

Noah said:
Is there a way for a test case method in a class derived
from unittest.TestCase to tell if the harness was started
with the verbose option? I would like my test cases to
print out a little extra information if the tests were run with
-v or -vv.

Looking at the source, it doesn't appear that information is exposed to
the TestCases. If you base your tests on this subclass of the standard
TestCase, however, you can use the regenerated "self._verbosity"
attribute to do what you want:


class TestCase(unittest.TestCase):
def run(self, result=None):
if result.showAll:
self._verbosity = 2
elif result.dots:
self._verbosity = 1
else:
self._verbosity = 0
unittest.TestCase.run(self, result=result)


-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top