コード例 #1
0
ファイル: test_logtools.py プロジェクト: cltrudeau/wrench
    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)
コード例 #2
0
ファイル: test_logtools.py プロジェクト: cltrudeau/wrench
    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)
コード例 #3
0
ファイル: test_contexts.py プロジェクト: cltrudeau/wrench
    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))
コード例 #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))
コード例 #5
0
ファイル: test_logtools.py プロジェクト: cltrudeau/wrench
    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())
コード例 #6
0
ファイル: test_logtools.py プロジェクト: cltrudeau/wrench
    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())
コード例 #7
0
 def setUpClass(cls):
     cls.temp_dir_cm = temp_directory()
     cls.dir_name = cls.temp_dir_cm.__enter__()
コード例 #8
0
 def setUpClass(cls):
     cls.temp_dir_cm = temp_directory()
     cls.dir_name = cls.temp_dir_cm.__enter__()