def test_default_logging_dict(self): msg = 'log message test_default_logging_dict' with capture_stderr() as output: with temp_directory() as td: d = default_logging_dict(td, handlers=['default', 'file']) logging.config.dictConfig(d) logger = logging.getLogger(__name__) logger.debug(msg) self._flush_logging() logfile = os.path.abspath(os.path.join(td, 'debug.log')) self.assert_in_file(msg, logfile) self.assertIn(msg, output.getvalue())
def test_capture_stderr(self): with capture_stderr() as capture: sys.stderr.write('foo\n') self.assertEqual(capture.getvalue(), 'foo\n')