From d21406dcb06588743dd2d9364657d057f799dd1c Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Sun, 23 Mar 2014 21:12:08 +0100 Subject: [PATCH] Use nose to capture logs during test Set the loglevel of beets to `DEBUG` but capture all logging statements with nose. The logs are only printed when a test fails. This gives us more information when tests fail while being completely silent on success. --- setup.cfg | 3 +++ test/_common.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..acd86dbcf --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[nosetests] +verbosity=1 +logging-clear-handlers=1 diff --git a/test/_common.py b/test/_common.py index a1d1c8d44..a912703ed 100644 --- a/test/_common.py +++ b/test/_common.py @@ -42,6 +42,11 @@ beetsplug.__path__ = [ os.path.abspath( # Test resources/sandbox path. RSRC = os.path.join(os.path.dirname(__file__), 'rsrc') +# Propagate to root loger so nosetest can capture it +log = logging.getLogger('beets') +log.propagate = True +log.setLevel(logging.DEBUG) + # Dummy item creation. _item_ident = 0 def item(lib=None): @@ -114,10 +119,6 @@ class TestCase(unittest.TestCase): # Initialize, but don't install, a DummyIO. self.io = DummyIO() - # Suppress logging output. - log = logging.getLogger('beets') - log.setLevel(logging.CRITICAL) - def tearDown(self): if os.path.isdir(self.temp_dir): shutil.rmtree(self.temp_dir)