When calling a test suite in the Python unittest framework, it is possible to give a -v
for higher level of verbosity, like:
python3 test_suite.py -v
How can a test case get access to the verbosity level ?
The verbosity isn't directly passed to TestCase
or TestSuite
since none of them actually need it for something. The runner
uses the verbosity information (the class running your tests) to handle the amount of information printed out.
Looking at the source, since argv
isn't cleared at any point, a non-intrusive way to check for the presense of the verbose flag would be to peek into argv
and see if '-v'
is inside it.
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