Ignore log messages during unit test capture
This commit is contained in:
@@ -228,6 +228,9 @@ def capture(stdin, bytesio=False):
|
|||||||
if stdin:
|
if stdin:
|
||||||
oldin = sys.stdin
|
oldin = sys.stdin
|
||||||
sys.stdin = stdin
|
sys.stdin = stdin
|
||||||
|
logger = logging.getLogger()
|
||||||
|
old_level = logger.getEffectiveLevel()
|
||||||
|
logger.setLevel(logging.CRITICAL)
|
||||||
try:
|
try:
|
||||||
output = [BytesIO() if bytesio else StringIO(), StringIO()]
|
output = [BytesIO() if bytesio else StringIO(), StringIO()]
|
||||||
sys.stdout, sys.stderr = output
|
sys.stdout, sys.stderr = output
|
||||||
@@ -236,6 +239,7 @@ def capture(stdin, bytesio=False):
|
|||||||
except SystemExit:
|
except SystemExit:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
logger.setLevel(old_level)
|
||||||
sys.stdout, sys.stderr = oldout, olderr
|
sys.stdout, sys.stderr = oldout, olderr
|
||||||
sys.exit = oldexit
|
sys.exit = oldexit
|
||||||
if stdin:
|
if stdin:
|
||||||
|
Reference in New Issue
Block a user