__init__.py 551 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python3
  2. """
  3. test.modtest_d.__init__: shared data for unit tests for the MMGen suite
  4. """
  5. import sys, os
  6. from mmgen.cfg import gv
  7. from ..include.common import cfg
  8. class unit_tests_base:
  9. silence_output = False
  10. def _silence(self):
  11. if not cfg.verbose:
  12. self.stdout_save = sys.stdout
  13. self.stderr_save = sys.stderr
  14. sys.stdout = sys.stderr = gv.stdout = gv.stderr = open(os.devnull, 'w')
  15. def _end_silence(self):
  16. if not cfg.verbose:
  17. sys.stdout = gv.stdout = self.stdout_save
  18. sys.stderr = gv.stderr = self.stderr_save