Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91d53e7

Browse files
committed
Make PyPIRCCommandTestCase derive from a base class
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.
1 parent 9e941d6 commit 91d53e7

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

Lib/distutils/tests/test_config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
"""
5353

5454

55-
class PyPIRCCommandTestCase(support.TempdirManager,
55+
class BasePyPIRCCommandTestCase(support.TempdirManager,
5656
support.LoggingSilencer,
5757
support.EnvironGuard,
5858
unittest.TestCase):
5959

6060
def setUp(self):
6161
"""Patches the environment."""
62-
super(PyPIRCCommandTestCase, self).setUp()
62+
super(BasePyPIRCCommandTestCase, self).setUp()
6363
self.tmp_dir = self.mkdtemp()
6464
os.environ['HOME'] = self.tmp_dir
6565
self.rc = os.path.join(self.tmp_dir, '.pypirc')
@@ -78,7 +78,10 @@ def initialize_options(self):
7878
def tearDown(self):
7979
"""Removes the patch."""
8080
set_threshold(self.old_threshold)
81-
super(PyPIRCCommandTestCase, self).tearDown()
81+
super(BasePyPIRCCommandTestCase, self).tearDown()
82+
83+
84+
class PyPIRCCommandTestCase(BasePyPIRCCommandTestCase):
8285

8386
def test_server_registration(self):
8487
# This test makes sure PyPIRCCommand knows how to:

Lib/distutils/tests/test_register.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from distutils.errors import DistutilsSetupError
1313
from distutils.log import INFO
1414

15-
from distutils.tests.test_config import PyPIRCCommandTestCase
15+
from distutils.tests.test_config import BasePyPIRCCommandTestCase
1616

1717
try:
1818
import docutils
@@ -72,7 +72,7 @@ def getheader(self, name, default=None):
7272
}.get(name.lower(), default)
7373

7474

75-
class RegisterTestCase(PyPIRCCommandTestCase):
75+
class RegisterTestCase(BasePyPIRCCommandTestCase):
7676

7777
def setUp(self):
7878
super(RegisterTestCase, self).setUp()

Lib/distutils/tests/test_sdist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from distutils.command.sdist import sdist, show_formats
2525
from distutils.core import Distribution
26-
from distutils.tests.test_config import PyPIRCCommandTestCase
26+
from distutils.tests.test_config import BasePyPIRCCommandTestCase
2727
from distutils.errors import DistutilsOptionError
2828
from distutils.spawn import find_executable
2929
from distutils.log import WARN
@@ -52,7 +52,7 @@
5252
somecode%(sep)sdoc.txt
5353
"""
5454

55-
class SDistTestCase(PyPIRCCommandTestCase):
55+
class SDistTestCase(BasePyPIRCCommandTestCase):
5656

5757
def setUp(self):
5858
# PyPIRCCommandTestCase creates a temp dir already

Lib/distutils/tests/test_upload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from distutils.errors import DistutilsError
1313
from distutils.log import ERROR, INFO
1414

15-
from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
15+
from distutils.tests.test_config import PYPIRC, BasePyPIRCCommandTestCase
1616

1717
PYPIRC_LONG_PASSWORD = """\
1818
[distutils]
@@ -66,7 +66,7 @@ def getcode(self):
6666
return self.code
6767

6868

69-
class uploadTestCase(PyPIRCCommandTestCase):
69+
class uploadTestCase(BasePyPIRCCommandTestCase):
7070

7171
def setUp(self):
7272
super(uploadTestCase, self).setUp()

0 commit comments

Comments
 (0)