|
|
@ -9,11 +9,20 @@ import unittest |
|
|
|
import patacrep |
|
|
|
|
|
|
|
@contextlib.contextmanager |
|
|
|
def disable_logging(): |
|
|
|
"""Context locally disabling logging.""" |
|
|
|
logging.disable(logging.CRITICAL) |
|
|
|
yield |
|
|
|
logging.disable(logging.NOTSET) |
|
|
|
def logging_reduced(module_name=None, tmp_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) |
|
|
|
|
|
|
|
def suite(): |
|
|
|
"""Return a :class:`TestSuite` object, testing all module :mod:`patacrep`. |
|
|
|