Beispiel #1
0
    def test_config_file_logger(self):
        msg = 'log message test_config_file_logger'
        with temp_directory() as td:
            configure_file_logger('debug', td)
            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)
Beispiel #2
0
    def test_config_file_logger(self):
        msg = 'log message test_config_file_logger'
        with temp_directory() as td:
            configure_file_logger('debug', td)
            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)
Beispiel #3
0
    def test_temp_dir(self):
        created_td = ''
        with temp_directory() as td:
            created_td = td
            name = os.path.join(td, 'a.txt')
            with open(name, 'w') as f:
                f.write('foo')

            os.path.isfile(name)

        # verify that the temp directory has been cleaned up
        self.assertFalse(os.path.exists(created_td))

        # -- test failure still cleans up
        try:
            with temp_directory() as td:
                created_td = td
                raise RuntimeError()
        except:
            pass

        self.assertFalse(os.path.exists(created_td))
Beispiel #4
0
    def test_temp_dir(self):
        created_td = ''
        with temp_directory() as td:
            created_td = td
            name = os.path.join(td, 'a.txt')
            with open(name, 'w') as f:
                f.write('foo')

            os.path.isfile(name)

        # verify that the temp directory has been cleaned up
        self.assertFalse(os.path.exists(created_td))

        # -- test failure still cleans up
        try:
            with temp_directory() as td:
                created_td = td
                raise RuntimeError()
        except:
            pass

        self.assertFalse(os.path.exists(created_td))
Beispiel #5
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())
Beispiel #6
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())
 def setUpClass(cls):
     cls.temp_dir_cm = temp_directory()
     cls.dir_name = cls.temp_dir_cm.__enter__()
 def setUpClass(cls):
     cls.temp_dir_cm = temp_directory()
     cls.dir_name = cls.temp_dir_cm.__enter__()