mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
This commit is contained in:
parent
a4038038c6
commit
1369900619
8 changed files with 67 additions and 74 deletions
|
|
@ -2,6 +2,8 @@
|
|||
import sys
|
||||
import os
|
||||
import unittest
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
from distutils.core import PyPIRCCommand
|
||||
from distutils.core import Distribution
|
||||
|
|
@ -49,13 +51,15 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Patches the environment."""
|
||||
support.TempdirManager.setUp(self)
|
||||
|
||||
if os.environ.has_key('HOME'):
|
||||
self._old_home = os.environ['HOME']
|
||||
else:
|
||||
self._old_home = None
|
||||
curdir = os.path.dirname(__file__)
|
||||
os.environ['HOME'] = curdir
|
||||
self.rc = os.path.join(curdir, '.pypirc')
|
||||
self.tmp_dir = self.mkdtemp()
|
||||
os.environ['HOME'] = self.tmp_dir
|
||||
self.rc = os.path.join(self.tmp_dir, '.pypirc')
|
||||
self.dist = Distribution()
|
||||
|
||||
class command(PyPIRCCommand):
|
||||
|
|
@ -74,9 +78,8 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
|
|||
del os.environ['HOME']
|
||||
else:
|
||||
os.environ['HOME'] = self._old_home
|
||||
if os.path.exists(self.rc):
|
||||
os.remove(self.rc)
|
||||
set_threshold(self.old_threshold)
|
||||
support.TempdirManager.tearDown(self)
|
||||
|
||||
def test_server_registration(self):
|
||||
# This test makes sure PyPIRCCommand knows how to:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue