From 24304636d9314b2ddafd77a3576900c3b6ddcf8f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 14 Apr 2019 00:39:53 -0400 Subject: [PATCH] Add test util to mute output to stdout Used by the tests of the autoadmin app. Signed-off-by: Roberto Rosario --- mayan/apps/common/tests/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 mayan/apps/common/tests/utils.py diff --git a/mayan/apps/common/tests/utils.py b/mayan/apps/common/tests/utils.py new file mode 100644 index 0000000000..e6702dc09f --- /dev/null +++ b/mayan/apps/common/tests/utils.py @@ -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 +