]> granicus.if.org Git - python/commitdiff
make sure distutils logging is shut off in tests to avoid spurious output
authorFred Drake <fdrake@acm.org>
Tue, 3 Aug 2004 18:53:07 +0000 (18:53 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 3 Aug 2004 18:53:07 +0000 (18:53 +0000)
Lib/distutils/log.py
Lib/distutils/tests/support.py
Lib/distutils/tests/test_build_py.py
Lib/distutils/tests/test_build_scripts.py
Lib/distutils/tests/test_install_scripts.py

index 024e7c28dec70fe39bb49080f2064add3b6ef00f..bf26302fcc4c1d5c41eb124584031e152dd42a53 100644 (file)
@@ -50,7 +50,10 @@ error = _global_log.error
 fatal = _global_log.fatal
 
 def set_threshold(level):
+    # return the old threshold for use from tests
+    old = _global_log.threshold
     _global_log.threshold = level
+    return old
 
 def set_verbosity(v):
     if v <= 0:
index cef985d79af01f24ea948af3ab18d26d9ce9cda0..475ceee598bd76cdc6f13b5bd9257614f235c75d 100644 (file)
@@ -3,6 +3,19 @@
 import shutil
 import tempfile
 
+from distutils import log
+
+
+class LoggingSilencer(object):
+
+    def setUp(self):
+        super(LoggingSilencer, self).setUp()
+        self.threshold = log.set_threshold(log.FATAL)
+
+    def tearDown(self):
+        log.set_threshold(self.threshold)
+        super(LoggingSilencer, self).tearDown()
+
 
 class TempdirManager(object):
     """Mix-in class that handles temporary directories for test cases.
index 6f7276866d5e4b50ad46946fc7654a573ffee6ab..78e4c55ed4839584137731b9006f29be631af8a4 100644 (file)
@@ -9,7 +9,9 @@ from distutils.core import Distribution
 from distutils.tests import support
 
 
-class BuildPyTestCase(support.TempdirManager, unittest.TestCase):
+class BuildPyTestCase(support.TempdirManager,
+                      support.LoggingSilencer,
+                      unittest.TestCase):
 
     def test_package_data(self):
         sources = self.mkdtemp()
index 7ef71cc120e8faac00789a108ca49f737a5168ac..bf25b3822202a5306233360590a2231ebd5d77df 100644 (file)
@@ -9,7 +9,9 @@ from distutils.core import Distribution
 from distutils.tests import support
 
 
-class BuildScriptsTestCase(support.TempdirManager, unittest.TestCase):
+class BuildScriptsTestCase(support.TempdirManager,
+                           support.LoggingSilencer,
+                           unittest.TestCase):
 
     def test_default_settings(self):
         cmd = self.get_build_scripts_cmd("/foo/bar", [])
index 2e86dcd8a9fa793e1f22a62462c69a456cd4e52b..fffa6ef2c3a4a0d7d715146e2f3559a1f8e4ba99 100644 (file)
@@ -9,7 +9,9 @@ from distutils.core import Distribution
 from distutils.tests import support
 
 
-class InstallScriptsTestCase(support.TempdirManager, unittest.TestCase):
+class InstallScriptsTestCase(support.TempdirManager,
+                             support.LoggingSilencer,
+                             unittest.TestCase):
 
     def test_default_settings(self):
         dist = Distribution()