Browse Source

[test] Disabling logging during tests

pull/79/head
Louis 9 years ago
parent
commit
eb9c8618d8
  1. 3
      patacrep/songs/chordpro/test/test_parser.py
  2. 10
      patacrep/test.py

3
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,6 +36,7 @@ class ParserTxtRenderer(unittest.TestCase):
})
with open("{}.txt".format(self.basename), 'r', encoding='utf8') as expectfile:
chordproname = "{}.sgc".format(self.basename)
with disable_logging():
self.assertMultiLineEqual(
ChordproSong(None, chordproname, config).render(
output=chordproname,

10
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())

Loading…
Cancel
Save