I have a module mymodule
that I test with unittest
. The module logs to stdout diagnostics messages when is in verbose mode (e.g. mymodule.set_verbose(True)
) and remains silent otherwise. I would like that when I import the module in the main program it is in the silent mode and when the unittest
runs, it is verbose.
I tried to hack it in the unittest main loop, but it doesn't work
if __name__ == "__main__":
mymodule.set_verbose( True )
unittest.main()
# apparently, modules are loaded on each test separately
How to increase verbosity in python unittest? was not helpful.