Browse Source

[test] Simplify `logging_reduced` function

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

13
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)
logger.setLevel(level)
yield
logger.setLevel(old_level)
else:
logging.disable(logging.CRITICAL)
yield
logging.disable(logging.NOTSET)
def suite():
"""Return a :class:`TestSuite` object, testing all module :mod:`patacrep`.

Loading…
Cancel
Save