diff --git a/patacrep/utils.py b/patacrep/utils.py index 998fe738..c096ac01 100644 --- a/patacrep/utils.py +++ b/patacrep/utils.py @@ -1,5 +1,8 @@ """Some utility functions""" +import contextlib +import logging + from collections import UserDict class DictOfDict(UserDict): @@ -75,3 +78,11 @@ def yesno(string): string, ", ".join(["'{}'".format(string) for string in yes_strings + no_strings]), )) + +@contextlib.contextmanager +def logging_reduced(module_name): + logger = logging.getLogger(module_name) + previous_loglevel = logger.getEffectiveLevel() + logger.setLevel(logging.CRITICAL) + yield + logger.setLevel(previous_loglevel) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 2ba42590..7532450e 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -10,6 +10,7 @@ import json from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep import content, files from patacrep.content import song, section, songsection, tex +from patacrep.utils import logging_reduced from .. import dynamic # pylint: disable=unused-import @@ -51,7 +52,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): with open(sourcename, mode="r", encoding="utf8") as sourcefile: sbcontent = json.load(sourcefile) - expandedlist = content.process_content(sbcontent, cls.config.copy()) + with logging_reduced('patacrep.content.song'): + expandedlist = content.process_content(sbcontent, cls.config.copy()) sourcelist = [cls._clean_path(elem) for elem in expandedlist] controlname = "{}.control".format(base)