blob: c4a627ff7a1a9989b634d1a1a8f6880de66eab5a [file] [log] [blame]
import contextlib
import io
import sys
import unittest
class CfgCheckerTestBase(unittest.TestCase):
dummy_base_var = 0
def _safe_import_module(self, _str):
_import_msg = ""
_module = None
try:
_module = __import__(_str)
except ImportError as e:
_import_msg = e.message
return _import_msg, _module
@contextlib.contextmanager
def redirect_output(self):
save_stdout = sys.stdout
save_stderr = sys.stderr
sys.stdout = io.BytesIO()
sys.stderr = io.BytesIO()
yield
sys.stdout = save_stdout
sys.stderr = save_stderr