]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make PyPIRCCommandTestCase derive from a base class
authorBerker Peksag <berker.peksag@gmail.com>
Fri, 24 Jun 2016 05:48:27 +0000 (08:48 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Fri, 24 Jun 2016 05:48:27 +0000 (08:48 +0300)
Several test cases in distutils use PyPIRCCommandTestCase as
their base class and as a result of that the following tests
were ran more than once:

* test_server_registration
* test_server_empty_registration
* test_config_interpolation

This commit moves the infrastructure used by other tests
into a new BasePyPIRCCommandTestCase class.

Lib/distutils/tests/test_config.py
Lib/distutils/tests/test_register.py
Lib/distutils/tests/test_sdist.py
Lib/distutils/tests/test_upload.py

index 0b91d19a54c3286218ee5f3079597260e99e7779..3dd92d6166604ae559233a8d1b6d4fc6c2042862 100644 (file)
@@ -52,14 +52,14 @@ password:xxx
 """
 
 
-class PyPIRCCommandTestCase(support.TempdirManager,
+class BasePyPIRCCommandTestCase(support.TempdirManager,
                             support.LoggingSilencer,
                             support.EnvironGuard,
                             unittest.TestCase):
 
     def setUp(self):
         """Patches the environment."""
-        super(PyPIRCCommandTestCase, self).setUp()
+        super(BasePyPIRCCommandTestCase, self).setUp()
         self.tmp_dir = self.mkdtemp()
         os.environ['HOME'] = self.tmp_dir
         self.rc = os.path.join(self.tmp_dir, '.pypirc')
@@ -78,7 +78,10 @@ class PyPIRCCommandTestCase(support.TempdirManager,
     def tearDown(self):
         """Removes the patch."""
         set_threshold(self.old_threshold)
-        super(PyPIRCCommandTestCase, self).tearDown()
+        super(BasePyPIRCCommandTestCase, self).tearDown()
+
+
+class PyPIRCCommandTestCase(BasePyPIRCCommandTestCase):
 
     def test_server_registration(self):
         # This test makes sure PyPIRCCommand knows how to:
index 01acf2375f63bf0972da16b9a180bfa6b21d5d50..e68b0af3ce0c3ab53ae41d9dcc70ae14e57e4b52 100644 (file)
@@ -12,7 +12,7 @@ from distutils.command.register import register
 from distutils.errors import DistutilsSetupError
 from distutils.log import INFO
 
-from distutils.tests.test_config import PyPIRCCommandTestCase
+from distutils.tests.test_config import BasePyPIRCCommandTestCase
 
 try:
     import docutils
@@ -72,7 +72,7 @@ class FakeOpener(object):
             }.get(name.lower(), default)
 
 
-class RegisterTestCase(PyPIRCCommandTestCase):
+class RegisterTestCase(BasePyPIRCCommandTestCase):
 
     def setUp(self):
         super(RegisterTestCase, self).setUp()
index 5a04e0ddd0fd0cfd514d052a263116dd3a7e6875..5444b815a8b2349883ec5ade2583b63f2067fa5a 100644 (file)
@@ -23,7 +23,7 @@ except ImportError:
 
 from distutils.command.sdist import sdist, show_formats
 from distutils.core import Distribution
-from distutils.tests.test_config import PyPIRCCommandTestCase
+from distutils.tests.test_config import BasePyPIRCCommandTestCase
 from distutils.errors import DistutilsOptionError
 from distutils.spawn import find_executable
 from distutils.log import WARN
@@ -52,7 +52,7 @@ somecode%(sep)sdoc.dat
 somecode%(sep)sdoc.txt
 """
 
-class SDistTestCase(PyPIRCCommandTestCase):
+class SDistTestCase(BasePyPIRCCommandTestCase):
 
     def setUp(self):
         # PyPIRCCommandTestCase creates a temp dir already
index 3eecf8afd46de0407385ed3d2c36e5393a7b6e69..e836cc49471cd07f5eb5dc1b2df0816884df7713 100644 (file)
@@ -12,7 +12,7 @@ from distutils.core import Distribution
 from distutils.errors import DistutilsError
 from distutils.log import ERROR, INFO
 
-from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
+from distutils.tests.test_config import PYPIRC, BasePyPIRCCommandTestCase
 
 PYPIRC_LONG_PASSWORD = """\
 [distutils]
@@ -66,7 +66,7 @@ class FakeOpen(object):
         return self.code
 
 
-class uploadTestCase(PyPIRCCommandTestCase):
+class uploadTestCase(BasePyPIRCCommandTestCase):
 
     def setUp(self):
         super(uploadTestCase, self).setUp()