Ignore log messages during unit test capture

This commit is contained in:
Nick Hall 2017-05-11 15:03:42 +01:00
parent 07ce8c22d8
commit 0d704f03d8

View File

@ -228,6 +228,9 @@ def capture(stdin, bytesio=False):
if stdin:
oldin = sys.stdin
sys.stdin = stdin
logger = logging.getLogger()
old_level = logger.getEffectiveLevel()
logger.setLevel(logging.CRITICAL)
try:
output = [BytesIO() if bytesio else StringIO(), StringIO()]
sys.stdout, sys.stderr = output
@ -236,6 +239,7 @@ def capture(stdin, bytesio=False):
except SystemExit:
pass
finally:
logger.setLevel(old_level)
sys.stdout, sys.stderr = oldout, olderr
sys.exit = oldexit
if stdin: