The Python unittest framework has a concept of verbosity that I can't seem to find defined anywhere. For instance, I'm running test cases like this (like in the documentation):
suite = unittest.TestLoader().loadTestsFromTestCase(MyAwesomeTest) unittest.TextTestRunner(verbosity=2).run(suite)
The only number I've ever seen passed as verbosity is 2. What is this magic number, what does it mean, what what else can I pass?
VERBOSE : This flag allows you to write regular expressions that look nicer and are more readable by allowing you to visually separate logical sections of the pattern and add comments.
TestCase is used to create test cases by subclassing it. The last block of the code at the bottom allows us to run all the tests just by running the file.
A unit test is a test that checks a single component of code, usually modularized as a function, and ensures that it performs as expected. Unit tests are an important part of regression testing to ensure that the code still functions as expected after making changes to the code and helps ensure code stability.
You only have 3 different levels:
You can use command line args rather than the verbosity argument: --quiet
and --verbose
which would do something similar to passing 0 or 2 to the runner.
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