Reputation: 1221
How do I get access to Python 3.8 doctest verbose flag inside a test?
I see it as DocTestRunner._verbose
but I would need an instance to grab it from.
I'm trying to do something like
def MyClass
"""
>>> if doctest.DocTestRunner.instance._verbose: printFancyStuffToStdErr() # how do I get instance?
"""
...
if __name__ == '__main__':
import doctest, os, sys
if someCondition(): # n.b. this is simplification and not available inside test
res = doctest.testmod(verbose=True)
else
res = doctest.testmod(verbose=False)
NB this is NOT the same as How can a test in Python unittest get access to the verbosity level? the answer to which grabs the '-v' or '--verbose' from the command line
Upvotes: 0
Views: 99