Browse Source

Reduce logging for test_content

pull/179/head
Oliverpool 9 years ago
parent
commit
a1c41f4333
  1. 11
      patacrep/utils.py
  2. 4
      test/test_content/test_content.py

11
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)

4
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)

Loading…
Cancel
Save