Reputation: 1840
What is the verbosity level in python. I see it in unittest.
In documentation it just say simply that higher verbosity level, more info print out. but more means what? That is to say, which message will be printed out in a higher level and which will not?
Also find verbosity in logging.
I think they are different due to the reason that logging verbosity level is in [0, 50] and unittest's is just a unit number. I just want to find out the difference between each verbosity level in unittests.
Upvotes: 4
Views: 20129
Reputation: 8307
Verbosity level is related just to logging. In unit tests you find it for the logging of the information.
Note: It is more pythonic to use levels as constant names(logging.INFO
, logging.DEBUG
rather than numbers.
These levels decide the amount of information you will get. For example setting the level to ERROR
for running unit tests will display only the cases for which the unit tests failed. Setting it to DEBUG
will give you more (the most in fact) info such as what were the values of the variables (in assert statements etc).
It is more useful in cases where your program has different levels of logging and you want your users to see different levels of info. For eg. usually you don't want the users to see details of internals, apart from fatal errors. So users will be running the program in FATAL or CRITICAL mode. But when some error occurs you will need such details. In this case you will run the program in debug mode. You can issue custom messages with these levels too. For eg, if you are providing back compatibility with older versions of your program, you can WARN them with logging.warn()
, which will be issued only when the logging level is warning or less.
DOCS:
Default levels and level names, these can be replaced with any positive set of values having corresponding names. There is a pseudo-level, NOTSET, which is only really there as a lower limit for user-defined levels. Handlers and loggers are initialized with NOTSET so that they will log all messages, even at user-defined levels.
CRITICAL = 50
FATAL = CRITICAL
ERROR = 40
WARNING = 30
WARN = WARNING
INFO = 20
DEBUG = 10
NOTSET = 0
Upvotes: 2