本文整理汇总了Python中nose.plugins.logcapture.LogCapture.formatLogRecords方法的典型用法代码示例。如果您正苦于以下问题:Python LogCapture.formatLogRecords方法的具体用法?Python LogCapture.formatLogRecords怎么用?Python LogCapture.formatLogRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.plugins.logcapture.LogCapture
的用法示例。
在下文中一共展示了LogCapture.formatLogRecords方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_formatter
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_custom_formatter(self):
c = LogCapture()
c.logformat = '++%(message)s++'
c.start()
log = logging.getLogger("foobar.something")
log.debug("Hello")
c.end()
records = c.formatLogRecords()
eq_(1, len(records))
eq_("++Hello++", records[0])
示例2: test_loglevel
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_loglevel(self):
c = LogCapture()
parser = OptionParser()
c.addOptions(parser, {})
options, args = parser.parse_args(['--logging-level', 'INFO'])
c.configure(options, Config())
c.start()
log = logging.getLogger("loglevel")
log.debug("Hello")
log.info("Goodbye")
c.end()
records = c.formatLogRecords()
eq_(1, len(c.handler.buffer))
eq_("loglevel: INFO: Goodbye", c.handler.buffer[0])
eq_("loglevel: INFO: Goodbye", records[0])
示例3: test_logging
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_logging():
c = LogCapture()
parser = OptionParser()
c.addOptions(parser, {})
logger = klogger.get_logger("foo")
logger = klogger.get_module_logger(__name__)
c.start()
logger.info("Goodbye")
c.end()
records = c.formatLogRecords()
eq_("Goodbye", c.handler.buffer[0].msg)
eq_("test.helpers.klogger_test", c.handler.buffer[0].name)
eq_("test.helpers.klogger_test: INFO: Goodbye", records[0])
示例4: test_consistent_mutables
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_consistent_mutables(self):
c = LogCapture()
parser = OptionParser()
c.addOptions(parser)
c.start()
log = logging.getLogger("mutable")
mutable = { 'value': 1 }
log.debug("%r", mutable)
repr_1 = repr(mutable)
mutable['value'] = 2
log.debug("%r", mutable)
repr_2 = repr(mutable)
c.end()
records = c.formatLogRecords()
eq_("mutable: DEBUG: %s" % (repr_1,), records[0])
eq_("mutable: DEBUG: %s" % (repr_2,), records[1])
示例5: test_logging_filter_exclude_and_include
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_logging_filter_exclude_and_include(self):
env = {'NOSE_LOGFILTER': 'foo,-foo.bar'}
c = LogCapture()
parser = OptionParser()
c.addOptions(parser, env)
options, args = parser.parse_args(['foo'])
print options, args
c.configure(options, Config())
c.start()
for name in ['foo.yes', 'foo.bar', 'foo.bar.no', 'blah']:
log = logging.getLogger(name)
log.info("Hello %s" % name)
c.end()
records = c.formatLogRecords()
eq_(1, len(records))
assert records[0].startswith('foo.yes:'), records[0]
示例6: test_logging_filter_exclude
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_logging_filter_exclude(self):
env = {'NOSE_LOGFILTER': '-foo,-bar'}
c = LogCapture()
parser = OptionParser()
c.addOptions(parser, env)
options, args = parser.parse_args(['foo'])
print options, args
c.configure(options, Config())
c.start()
for name in ['foobar.something', 'foo', 'foo.x', 'abara', 'bar.quux']:
log = logging.getLogger(name)
log.info("Hello %s" % name)
c.end()
records = c.formatLogRecords()
eq_(2, len(records))
assert records[0].startswith('foobar.something:'), records[0]
assert records[1].startswith('abara:'), records[1]
示例7: test_non_propagating_loggers_handled
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_non_propagating_loggers_handled(self):
c = LogCapture()
parser = OptionParser()
c.addOptions(parser, {})
options, args = parser.parse_args([])
c.configure(options, Config())
logger = logging.getLogger('foo.yes')
logger.propagate = False
c.start()
logger.debug("test message")
c.end()
records = c.formatLogRecords()
eq_(1, len(records))
assert records[0].startswith('foo.yes:'), records[0]
示例8: test_builtin_logging_filtering
# 需要导入模块: from nose.plugins.logcapture import LogCapture [as 别名]
# 或者: from nose.plugins.logcapture.LogCapture import formatLogRecords [as 别名]
def test_builtin_logging_filtering(self):
c = LogCapture()
c.logformat = '++%(message)s++'
c.start()
log = logging.getLogger("foobar.something")
filtered = []
class filter(object):
def filter(record):
filtered.append(record)
return len(filtered) == 1
filter = staticmethod(filter)
c.handler.addFilter(filter)
log.debug("Hello")
log.debug("World")
c.end()
eq_(2, len(filtered))
records = c.formatLogRecords()
eq_(1, len(records))
eq_("++Hello++", records[0])