Exemplo n.º 1
0
    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())
Exemplo n.º 2
0
    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())
Exemplo n.º 3
0
    def test_capture_stderr(self):
        with capture_stderr() as capture:
            sys.stderr.write('foo\n')

        self.assertEqual(capture.getvalue(), 'foo\n')
Exemplo n.º 4
0
    def test_capture_stderr(self):
        with capture_stderr() as capture:
            sys.stderr.write('foo\n')

        self.assertEqual(capture.getvalue(), 'foo\n')