mirror of
https://github.com/python/cpython.git
synced 2025-07-22 10:45:22 +00:00
make sure distutils logging is shut off in tests to avoid spurious output
This commit is contained in:
parent
1fa649f2d5
commit
edcac8f416
5 changed files with 25 additions and 3 deletions
|
@ -50,7 +50,10 @@ error = _global_log.error
|
||||||
fatal = _global_log.fatal
|
fatal = _global_log.fatal
|
||||||
|
|
||||||
def set_threshold(level):
|
def set_threshold(level):
|
||||||
|
# return the old threshold for use from tests
|
||||||
|
old = _global_log.threshold
|
||||||
_global_log.threshold = level
|
_global_log.threshold = level
|
||||||
|
return old
|
||||||
|
|
||||||
def set_verbosity(v):
|
def set_verbosity(v):
|
||||||
if v <= 0:
|
if v <= 0:
|
||||||
|
|
|
@ -3,6 +3,19 @@
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
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):
|
class TempdirManager(object):
|
||||||
"""Mix-in class that handles temporary directories for test cases.
|
"""Mix-in class that handles temporary directories for test cases.
|
||||||
|
|
|
@ -9,7 +9,9 @@ from distutils.core import Distribution
|
||||||
from distutils.tests import support
|
from distutils.tests import support
|
||||||
|
|
||||||
|
|
||||||
class BuildPyTestCase(support.TempdirManager, unittest.TestCase):
|
class BuildPyTestCase(support.TempdirManager,
|
||||||
|
support.LoggingSilencer,
|
||||||
|
unittest.TestCase):
|
||||||
|
|
||||||
def test_package_data(self):
|
def test_package_data(self):
|
||||||
sources = self.mkdtemp()
|
sources = self.mkdtemp()
|
||||||
|
|
|
@ -9,7 +9,9 @@ from distutils.core import Distribution
|
||||||
from distutils.tests import support
|
from distutils.tests import support
|
||||||
|
|
||||||
|
|
||||||
class BuildScriptsTestCase(support.TempdirManager, unittest.TestCase):
|
class BuildScriptsTestCase(support.TempdirManager,
|
||||||
|
support.LoggingSilencer,
|
||||||
|
unittest.TestCase):
|
||||||
|
|
||||||
def test_default_settings(self):
|
def test_default_settings(self):
|
||||||
cmd = self.get_build_scripts_cmd("/foo/bar", [])
|
cmd = self.get_build_scripts_cmd("/foo/bar", [])
|
||||||
|
|
|
@ -9,7 +9,9 @@ from distutils.core import Distribution
|
||||||
from distutils.tests import support
|
from distutils.tests import support
|
||||||
|
|
||||||
|
|
||||||
class InstallScriptsTestCase(support.TempdirManager, unittest.TestCase):
|
class InstallScriptsTestCase(support.TempdirManager,
|
||||||
|
support.LoggingSilencer,
|
||||||
|
unittest.TestCase):
|
||||||
|
|
||||||
def test_default_settings(self):
|
def test_default_settings(self):
|
||||||
dist = Distribution()
|
dist = Distribution()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue