Add test util to mute output to stdout

Used by the tests of the autoadmin app.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-04-14 00:39:53 -04:00
parent 9b2633e6c7
commit 24304636d9

View File

@@ -0,0 +1,16 @@
from contextlib import contextmanager
import sys
class NullFile(object):
def write(self, string):
"""Writes here go nowhere"""
@contextmanager
def mute_stdout():
stdout_old = sys.stdout
sys.stdout = NullFile()
yield
sys.stdout = stdout_old