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:
16
mayan/apps/common/tests/utils.py
Normal file
16
mayan/apps/common/tests/utils.py
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user