예제 #1
0
 def capture_stderr_call(self):
     old_stderr = sys.stderr
     listener = io.StringIO()
     sys.stderr = listener
     log = Logger().logger
     log.critical('SomeString')
     log.error('SomeString')
     out = listener.getvalue()
     sys.stderr = old_stderr
     self.assertGreater(len(out), 0)
     return out
예제 #2
0
    def test_stdout(self):
        print('Levels WARNING, ERROR and CRITICAL not present in stdout')
        old_stdout = sys.stdout
        listener = io.StringIO()
        sys.stdout = listener

        log = Logger().logger
        log.warning(self.not_present_string)
        log.error(self.not_present_string)
        log.critical(self.not_present_string)

        out = listener.getvalue()
        sys.stdout = old_stdout

        self.assertNotIn(self.not_present_string, out)