test_configuration.py 文件源码

python
阅读 42 收藏 0 点赞 0 评论 0

项目:Safe-RL-Benchmark 作者: befelix 项目源码 文件源码
def test_logger_format(self):
        """Test: CONFIG: logger format."""
        config = SRBConfig(logger)

        config.logger_add_stream_handler()
        config.logger_add_file_handler('logs.log')

        fmt = '%(name)s - %(levelname)s - %(message)s'
        formatter = logging.Formatter(fmt)

        config.logger_format = fmt

        tst_record = {
            'name': 'test_logger',
            'level': logging.DEBUG,
            'pathname': os.path.realpath(__file__),
            'lineno': 42,
            'msg': 'test_msg',
            'args': None,
            'exc_info': None,
            'func': 'test_logger_format'
        }
        rec = logging.makeLogRecord(tst_record)
        self.assertEqual(formatter.format(rec),
                         config.logger_stream_handler.format(rec))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号