catching_logs: Remove usage of 'closing' ctx manager

The 'closing' context manager is only needed for the log_file_handler.
This commit is contained in:
Thomas Hisch 2017-09-15 13:38:49 +02:00
parent 57f66a455a
commit 3a4011585f
1 changed files with 7 additions and 8 deletions

View File

@ -127,11 +127,9 @@ def catching_logs(handler, formatter=None,
handler.setFormatter(formatter) handler.setFormatter(formatter)
handler.setLevel(level) handler.setLevel(level)
with closing(handler): with logging_using_handler(handler, logger):
with logging_using_handler(handler, logger): with logging_at_level(min(handler.level, logger.level), logger):
with logging_at_level(min(handler.level, logger.level), logger): yield handler
yield handler
class LogCaptureHandler(logging.StreamHandler): class LogCaptureHandler(logging.StreamHandler):
@ -421,8 +419,9 @@ class LoggingPlugin(object):
"""Runs all collected test items.""" """Runs all collected test items."""
with self.live_logs: with self.live_logs:
if self.log_file_handler is not None: if self.log_file_handler is not None:
with catching_logs(self.log_file_handler, with closing(self.log_file_handler):
level=self.log_file_level): with catching_logs(self.log_file_handler,
yield # run all the tests level=self.log_file_level):
yield # run all the tests
else: else:
yield # run all the tests yield # run all the tests