From 059e4412468bce0211e10ae8ed275122acd758b1 Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Fri, 4 Sep 2015 15:05:50 +0100 Subject: Fix logcapture plugin to capture output from non-propagating loggers, and to not output 'no handlers could be found' message --- unit_tests/test_logcapture_plugin.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'unit_tests') diff --git a/unit_tests/test_logcapture_plugin.py b/unit_tests/test_logcapture_plugin.py index 63aa651..1f2d50f 100644 --- a/unit_tests/test_logcapture_plugin.py +++ b/unit_tests/test_logcapture_plugin.py @@ -255,3 +255,21 @@ class TestLogCapturePlugin(object): assert msg in ev else: assert msg.encode('utf-8') in ev + + 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] -- cgit v1.2.1