Browse Source

[test] Simplify `logging_reduced` function

pull/188/head
Louis 9 years ago
parent
commit
d654dbf2b2
  1. 21
      test/__init__.py

21
test/__init__.py

@ -9,20 +9,15 @@ import unittest
import patacrep import patacrep
@contextlib.contextmanager @contextlib.contextmanager
def logging_reduced(module_name=None, tmp_level=logging.CRITICAL): def logging_reduced(module_name=None, level=logging.CRITICAL):
"""Temporarly reduce the logging level of a specific module """Temporarly reduce the logging level of a specific module or globally if None
or globally if None
""" """
if module_name: logger = logging.getLogger(module_name)
logger = logging.getLogger(module_name) old_level = logger.getEffectiveLevel()
old_level = logger.getEffectiveLevel()
logger.setLevel(tmp_level) logger.setLevel(level)
yield yield
logger.setLevel(old_level) logger.setLevel(old_level)
else:
logging.disable(logging.CRITICAL)
yield
logging.disable(logging.NOTSET)
def suite(): def suite():
"""Return a :class:`TestSuite` object, testing all module :mod:`patacrep`. """Return a :class:`TestSuite` object, testing all module :mod:`patacrep`.

Loading…
Cancel
Save