summaryrefslogtreecommitdiff
path: root/tests/testutil.py
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-10-27 15:23:33 +0200
committerMichał Górny <mgorny@gentoo.org>2017-10-27 15:42:14 +0200
commita858b23414005c13f208cbfcaa070784f923ea61 (patch)
treeb74f97010ec0a7e315e47e1029d5704e860322ad /tests/testutil.py
parent4515573f29b9e0862ff4f72419eedfca18233c79 (diff)
downloadgemato-a858b23414005c13f208cbfcaa070784f923ea61.tar.gz
testutil: Handle silencing logging for tests
Diffstat (limited to 'tests/testutil.py')
-rw-r--r--tests/testutil.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/testutil.py b/tests/testutil.py
index 170b83b..e02ea70 100644
--- a/tests/testutil.py
+++ b/tests/testutil.py
@@ -4,17 +4,30 @@
# Licensed under the terms of 2-clause BSD license
import io
+import logging
import os
import os.path
import tempfile
import unittest
-class TempDirTestCase(unittest.TestCase):
+class LoggingTestCase(unittest.TestCase):
+ def setUp(self):
+ self.log = io.StringIO()
+ self.log_handler = logging.getLogger().addHandler(
+ logging.StreamHandler(self.log))
+
+ def tearDown(self):
+ # TODO: make some use of the log output?
+ logging.getLogger().removeHandler(self.log_handler)
+
+
+class TempDirTestCase(LoggingTestCase):
DIRS = []
FILES = {}
def setUp(self):
+ super(TempDirTestCase, self).setUp()
self.dir = tempfile.mkdtemp()
for k in self.DIRS:
os.mkdir(os.path.join(self.dir, k))
@@ -28,3 +41,4 @@ class TempDirTestCase(unittest.TestCase):
for k in reversed(self.DIRS):
os.rmdir(os.path.join(self.dir, k))
os.rmdir(self.dir)
+ super(TempDirTestCase, self).tearDown()