diff --git a/patacrep/songs/chordpro/test/test_parser.py b/patacrep/songs/chordpro/test/test_parser.py index 8fdedc22..2fc89ca6 100644 --- a/patacrep/songs/chordpro/test/test_parser.py +++ b/patacrep/songs/chordpro/test/test_parser.py @@ -8,6 +8,8 @@ import unittest from patacrep.build import DEFAULT_CONFIG from patacrep.songs.chordpro import ChordproSong +from patacrep.test import disable_logging + class ParserTxtRenderer(unittest.TestCase): """Test parser, and renderer as a txt file.""" @@ -34,16 +36,17 @@ class ParserTxtRenderer(unittest.TestCase): }) with open("{}.txt".format(self.basename), 'r', encoding='utf8') as expectfile: chordproname = "{}.sgc".format(self.basename) - self.assertMultiLineEqual( - ChordproSong(None, chordproname, config).render( - output=chordproname, - output_format="chordpro", - ).strip(), - expectfile.read().replace( - "DIRNAME", - os.path.dirname(self.basename), - ).strip(), - ) + with disable_logging(): + self.assertMultiLineEqual( + ChordproSong(None, chordproname, config).render( + output=chordproname, + output_format="chordpro", + ).strip(), + expectfile.read().replace( + "DIRNAME", + os.path.dirname(self.basename), + ).strip(), + ) def load_tests(__loader, tests, __pattern): """Load several tests given test files present in the directory.""" diff --git a/patacrep/test.py b/patacrep/test.py index ce135fef..1a1eaae4 100644 --- a/patacrep/test.py +++ b/patacrep/test.py @@ -1,11 +1,20 @@ """Tests""" +import contextlib import doctest +import logging import os import unittest import patacrep +@contextlib.contextmanager +def disable_logging(): + """Context locally disabling logging.""" + logging.disable(logging.CRITICAL) + yield + logging.disable(logging.NOTSET) + def suite(): """Return a TestSuite object, to test whole `patacrep` package. @@ -24,3 +33,4 @@ def load_tests(__loader, tests, __pattern): if __name__ == "__main__": unittest.TextTestRunner().run(suite()) +