From d654dbf2b2c67ca76227bcb9032fe8723f353f07 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 23 Nov 2015 22:34:59 +0100 Subject: [PATCH] [test] Simplify `logging_reduced` function --- test/__init__.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/test/__init__.py b/test/__init__.py index 41fb4a66..d77a9c27 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -9,20 +9,15 @@ import unittest import patacrep @contextlib.contextmanager -def logging_reduced(module_name=None, tmp_level=logging.CRITICAL): - """Temporarly reduce the logging level of a specific module - or globally if None +def logging_reduced(module_name=None, level=logging.CRITICAL): + """Temporarly reduce the logging level of a specific module or globally if None """ - if module_name: - logger = logging.getLogger(module_name) - old_level = logger.getEffectiveLevel() - logger.setLevel(tmp_level) - yield - logger.setLevel(old_level) - else: - logging.disable(logging.CRITICAL) - yield - logging.disable(logging.NOTSET) + logger = logging.getLogger(module_name) + old_level = logger.getEffectiveLevel() + + logger.setLevel(level) + yield + logger.setLevel(old_level) def suite(): """Return a :class:`TestSuite` object, testing all module :mod:`patacrep`.