summaryrefslogtreecommitdiff
path: root/nose/plugins
diff options
context:
space:
mode:
authorAdam Chainz <adam@adamj.eu>2015-09-04 15:05:50 +0100
committerAdam Chainz <adam@adamj.eu>2015-09-04 15:12:15 +0100
commit059e4412468bce0211e10ae8ed275122acd758b1 (patch)
tree403d39cc1ee3fdc32302dad70d08bf09c141f405 /nose/plugins
parent716d822d43db30195f795daa9fd71d54e682ec0c (diff)
downloadnose-059e4412468bce0211e10ae8ed275122acd758b1.tar.gz
Fix logcapture plugin to capture output from non-propagating loggers, and to not output 'no handlers could be found' message
Diffstat (limited to 'nose/plugins')
-rw-r--r--nose/plugins/logcapture.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/nose/plugins/logcapture.py b/nose/plugins/logcapture.py
index 4c9a79f..9623ae5 100644
--- a/nose/plugins/logcapture.py
+++ b/nose/plugins/logcapture.py
@@ -194,6 +194,13 @@ class LogCapture(Plugin):
if isinstance(handler, MyMemoryHandler):
root_logger.handlers.remove(handler)
root_logger.addHandler(self.handler)
+ # Also patch any non-propagating loggers in the tree
+ for logger in logging.Logger.manager.loggerDict.values():
+ if not getattr(logger, 'propagate', True) and hasattr(logger, "addHandler"):
+ for handler in logger.handlers[:]:
+ if isinstance(handler, MyMemoryHandler):
+ logger.handlers.remove(handler)
+ logger.addHandler(self.handler)
# to make sure everything gets captured
loglevel = getattr(self, "loglevel", "NOTSET")
root_logger.setLevel(getattr(logging, loglevel))