diff options
| author | ?ric Araujo <merwok@netwok.org> | 2010-08-15 04:02:25 +0200 |
|---|---|---|
| committer | ?ric Araujo <merwok@netwok.org> | 2010-08-15 04:02:25 +0200 |
| commit | 5572509c66371465161ad9395e49ce8f8babb9cd (patch) | |
| tree | 3afd077a92b6533f48fcb9520302481900c771ac /src/distutils2/tests | |
| parent | 20d80021213bedabd0647b35c943a89ea21f0fad (diff) | |
| download | disutils2-5572509c66371465161ad9395e49ce8f8babb9cd.tar.gz | |
Rename tests.support.LoggingSilencer to LoggingCatcher.
This change makes it clear that the mixin?s goal is not only to
silence logging output, but also to capture it and check it in
some circumstances. Thanks Alexis for the suggestion.
Diffstat (limited to 'src/distutils2/tests')
22 files changed, 36 insertions, 29 deletions
diff --git a/src/distutils2/tests/support.py b/src/distutils2/tests/support.py index 7da95c5..1ff2217 100644 --- a/src/distutils2/tests/support.py +++ b/src/distutils2/tests/support.py @@ -4,14 +4,14 @@ Always import unittest from this module, it will be the right version (standard library unittest for 3.2 and higher, third-party unittest2 release for older versions). -Four helper classes are provided: LoggingSilencer, TempdirManager, +Four helper classes are provided: LoggingCatcher, TempdirManager, EnvironGuard and WarningsCatcher. They are written to be used as mixins, e.g. :: from distutils2.tests.support import unittest - from distutils2.tests.support import LoggingSilencer + from distutils2.tests.support import LoggingCatcher - class SomeTestCase(LoggingSilencer, unittest.TestCase): + class SomeTestCase(LoggingCatcher, unittest.TestCase): If you need to define a setUp method on your test class, you have to call the mixin class' setUp method or it won't work (same thing for @@ -44,11 +44,11 @@ else: # external release of same package for older versions import unittest2 as unittest -__all__ = ['LoggingSilencer', 'WarningsCatcher', 'TempdirManager', +__all__ = ['LoggingCatcher', 'WarningsCatcher', 'TempdirManager', 'EnvironGuard', 'DummyCommand', 'unittest'] -class LoggingSilencer(object): +class LoggingCatcher(object): """TestCase-compatible mixin to catch logging calls. Every log message that goes through distutils2.log will get appended to @@ -58,7 +58,7 @@ class LoggingSilencer(object): """ def setUp(self): - super(LoggingSilencer, self).setUp() + super(LoggingCatcher, self).setUp() self.threshold = log.set_threshold(FATAL) # when log is replaced by logging we won't need # such monkey-patching anymore @@ -69,7 +69,7 @@ class LoggingSilencer(object): def tearDown(self): log.set_threshold(self.threshold) log.Log._log = self._old_log - super(LoggingSilencer, self).tearDown() + super(LoggingCatcher, self).tearDown() def _log(self, level, msg, args): if level not in (DEBUG, INFO, WARN, ERROR, FATAL): @@ -93,6 +93,13 @@ class LoggingSilencer(object): del self.logs[:] +class LoggingSilencer(object): + "Class that raises an exception to make sure the renaming is noticed." + + def __init__(self, *args): + raise DeprecationWarning("LoggingSilencer renamed to LoggingCatcher") + + class WarningsCatcher(object): def setUp(self): diff --git a/src/distutils2/tests/test_bdist_dumb.py b/src/distutils2/tests/test_bdist_dumb.py index 770827c..a33210e 100644 --- a/src/distutils2/tests/test_bdist_dumb.py +++ b/src/distutils2/tests/test_bdist_dumb.py @@ -27,7 +27,7 @@ setup(name='foo', version='0.1', py_modules=['foo'], """ class BuildDumbTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, support.EnvironGuard, unittest.TestCase): diff --git a/src/distutils2/tests/test_bdist_msi.py b/src/distutils2/tests/test_bdist_msi.py index 4ad54ef..0d3bda8 100644 --- a/src/distutils2/tests/test_bdist_msi.py +++ b/src/distutils2/tests/test_bdist_msi.py @@ -7,7 +7,7 @@ from distutils2.tests import support from distutils2.tests.support import unittest class BDistMSITestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): @unittest.skipUnless(sys.platform == "win32", "runs only on win32") diff --git a/src/distutils2/tests/test_bdist_wininst.py b/src/distutils2/tests/test_bdist_wininst.py index bd4f87e..f154463 100644 --- a/src/distutils2/tests/test_bdist_wininst.py +++ b/src/distutils2/tests/test_bdist_wininst.py @@ -7,7 +7,7 @@ from distutils2.tests import support from distutils2.tests.support import unittest class BuildWinInstTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_get_exe_bytes(self): diff --git a/src/distutils2/tests/test_build.py b/src/distutils2/tests/test_build.py index abf9ef8..1245111 100644 --- a/src/distutils2/tests/test_build.py +++ b/src/distutils2/tests/test_build.py @@ -11,7 +11,7 @@ except ImportError: from distutils2._backport.sysconfig import get_platform class BuildTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_finalize_options(self): diff --git a/src/distutils2/tests/test_build_clib.py b/src/distutils2/tests/test_build_clib.py index 348f700..b8d51d4 100644 --- a/src/distutils2/tests/test_build_clib.py +++ b/src/distutils2/tests/test_build_clib.py @@ -9,7 +9,7 @@ from distutils2.util import find_executable from distutils2.tests.support import unittest class BuildCLibTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_check_library_dist(self): diff --git a/src/distutils2/tests/test_build_ext.py b/src/distutils2/tests/test_build_ext.py index 1ae0bd8..eda8393 100644 --- a/src/distutils2/tests/test_build_ext.py +++ b/src/distutils2/tests/test_build_ext.py @@ -27,7 +27,7 @@ def _get_source_filename(): return os.path.join(CURDIR, 'xxmodule.c') class BuildExtTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def setUp(self): # Create a simple test environment diff --git a/src/distutils2/tests/test_build_py.py b/src/distutils2/tests/test_build_py.py index 54416c8..4ee15f1 100644 --- a/src/distutils2/tests/test_build_py.py +++ b/src/distutils2/tests/test_build_py.py @@ -13,7 +13,7 @@ from distutils2.tests.support import unittest class BuildPyTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_package_data(self): diff --git a/src/distutils2/tests/test_build_scripts.py b/src/distutils2/tests/test_build_scripts.py index 5c7d616..3982d99 100644 --- a/src/distutils2/tests/test_build_scripts.py +++ b/src/distutils2/tests/test_build_scripts.py @@ -14,7 +14,7 @@ from distutils2.tests.support import unittest class BuildScriptsTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_default_settings(self): diff --git a/src/distutils2/tests/test_check.py b/src/distutils2/tests/test_check.py index 02d171f..e6242cf 100644 --- a/src/distutils2/tests/test_check.py +++ b/src/distutils2/tests/test_check.py @@ -6,7 +6,7 @@ from distutils2.tests import support from distutils2.tests.support import unittest from distutils2.errors import DistutilsSetupError -class CheckTestCase(support.LoggingSilencer, +class CheckTestCase(support.LoggingCatcher, support.TempdirManager, unittest.TestCase): diff --git a/src/distutils2/tests/test_clean.py b/src/distutils2/tests/test_clean.py index dacf20a..acc5b66 100755..100644 --- a/src/distutils2/tests/test_clean.py +++ b/src/distutils2/tests/test_clean.py @@ -8,7 +8,7 @@ from distutils2.tests import support from distutils2.tests.support import unittest class cleanTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_simple_run(self): diff --git a/src/distutils2/tests/test_config_cmd.py b/src/distutils2/tests/test_config_cmd.py index 1995b0c..eab12fd 100644 --- a/src/distutils2/tests/test_config_cmd.py +++ b/src/distutils2/tests/test_config_cmd.py @@ -7,7 +7,7 @@ from distutils2.tests import support from distutils2.tests.support import unittest from distutils2 import log -class ConfigTestCase(support.LoggingSilencer, +class ConfigTestCase(support.LoggingCatcher, support.TempdirManager, unittest.TestCase): diff --git a/src/distutils2/tests/test_depgraph.py b/src/distutils2/tests/test_depgraph.py index 6ab265a..fa38b91 100644 --- a/src/distutils2/tests/test_depgraph.py +++ b/src/distutils2/tests/test_depgraph.py @@ -13,7 +13,7 @@ try: except ImportError: import StringIO -class DepGraphTestCase(support.LoggingSilencer, +class DepGraphTestCase(support.LoggingCatcher, unittest.TestCase): DISTROS_DIST = ('choxie', 'grammar', 'towel-stuff') diff --git a/src/distutils2/tests/test_dist.py b/src/distutils2/tests/test_dist.py index 125729c..254ce3b 100644 --- a/src/distutils2/tests/test_dist.py +++ b/src/distutils2/tests/test_dist.py @@ -38,7 +38,7 @@ class TestDistribution(Distribution): class DistributionTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, support.EnvironGuard, unittest.TestCase): diff --git a/src/distutils2/tests/test_install.py b/src/distutils2/tests/test_install.py index f3d9c59..5ec5f91 100644 --- a/src/distutils2/tests/test_install.py +++ b/src/distutils2/tests/test_install.py @@ -25,7 +25,7 @@ from distutils2.tests.support import unittest class InstallTestCase(support.TempdirManager, support.EnvironGuard, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_home_installation_scheme(self): diff --git a/src/distutils2/tests/test_install_data.py b/src/distutils2/tests/test_install_data.py index 48cea63..9cae44a 100644 --- a/src/distutils2/tests/test_install_data.py +++ b/src/distutils2/tests/test_install_data.py @@ -8,7 +8,7 @@ from distutils2.tests import support from distutils2.tests.support import unittest class InstallDataTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, support.EnvironGuard, unittest.TestCase): diff --git a/src/distutils2/tests/test_install_distinfo.py b/src/distutils2/tests/test_install_distinfo.py index fbfa722..1bad24b 100644 --- a/src/distutils2/tests/test_install_distinfo.py +++ b/src/distutils2/tests/test_install_distinfo.py @@ -34,7 +34,7 @@ class DummyInstallCmd(Command): class InstallDistinfoTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, support.EnvironGuard, unittest.TestCase): diff --git a/src/distutils2/tests/test_install_headers.py b/src/distutils2/tests/test_install_headers.py index 4e0dce7..5e40257 100644 --- a/src/distutils2/tests/test_install_headers.py +++ b/src/distutils2/tests/test_install_headers.py @@ -8,7 +8,7 @@ from distutils2.tests import support from distutils2.tests.support import unittest class InstallHeadersTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, support.EnvironGuard, unittest.TestCase): diff --git a/src/distutils2/tests/test_install_lib.py b/src/distutils2/tests/test_install_lib.py index a96c889..75eb69e 100644 --- a/src/distutils2/tests/test_install_lib.py +++ b/src/distutils2/tests/test_install_lib.py @@ -16,7 +16,7 @@ except AttributeError: bytecode_support = False class InstallLibTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, support.EnvironGuard, unittest.TestCase): diff --git a/src/distutils2/tests/test_install_scripts.py b/src/distutils2/tests/test_install_scripts.py index be65d65..2cfab03 100644 --- a/src/distutils2/tests/test_install_scripts.py +++ b/src/distutils2/tests/test_install_scripts.py @@ -10,7 +10,7 @@ from distutils2.tests.support import unittest class InstallScriptsTestCase(support.TempdirManager, - support.LoggingSilencer, + support.LoggingCatcher, unittest.TestCase): def test_default_settings(self): diff --git a/src/distutils2/tests/test_metadata.py b/src/distutils2/tests/test_metadata.py index 49a4757..931f1ba 100644 --- a/src/distutils2/tests/test_metadata.py +++ b/src/distutils2/tests/test_metadata.py @@ -7,11 +7,11 @@ from StringIO import StringIO from distutils2.metadata import (DistributionMetadata, _interpret, PKG_INFO_PREFERRED_VERSION) from distutils2.tests import run_unittest -from distutils2.tests.support import unittest, LoggingSilencer +from distutils2.tests.support import unittest, LoggingCatcher from distutils2.errors import (MetadataConflictError, MetadataUnrecognizedVersionError) -class DistributionMetadataTestCase(LoggingSilencer, unittest.TestCase): +class DistributionMetadataTestCase(LoggingCatcher, unittest.TestCase): def test_instantiation(self): PKG_INFO = os.path.join(os.path.dirname(__file__), 'PKG-INFO') diff --git a/src/distutils2/tests/test_sdist.py b/src/distutils2/tests/test_sdist.py index c68c9b1..4d9a9a0 100644 --- a/src/distutils2/tests/test_sdist.py +++ b/src/distutils2/tests/test_sdist.py @@ -58,7 +58,7 @@ somecode%(sep)sdoc.dat somecode%(sep)sdoc.txt """ -class SDistTestCase(support.TempdirManager, support.LoggingSilencer, +class SDistTestCase(support.TempdirManager, support.LoggingCatcher, support.EnvironGuard, unittest.TestCase): def setUp(self): |
