mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
now using EnvironGuard everywhere
This commit is contained in:
parent
d35f2a33d5
commit
450ca11a58
3 changed files with 25 additions and 71 deletions
|
@ -39,13 +39,13 @@ class TestDistribution(distutils.dist.Distribution):
|
|||
class DistributionTestCase(support.TempdirManager, unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
support.TempdirManager.setUp(self)
|
||||
super(DistributionTestCase, self).setUp()
|
||||
self.argv = sys.argv[:]
|
||||
del sys.argv[1:]
|
||||
|
||||
def tearDown(self):
|
||||
sys.argv[:] = self.argv
|
||||
support.TempdirManager.tearDown(self)
|
||||
super(DistributionTestCase, self).tearDown()
|
||||
|
||||
def create_distribution(self, configfiles=()):
|
||||
d = TestDistribution()
|
||||
|
@ -151,7 +151,8 @@ class DistributionTestCase(support.TempdirManager, unittest.TestCase):
|
|||
|
||||
self.assertEquals(len(warns), 0)
|
||||
|
||||
class MetadataTestCase(support.TempdirManager, unittest.TestCase):
|
||||
class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
|
||||
unittest.TestCase):
|
||||
|
||||
def test_simple_metadata(self):
|
||||
attrs = {"name": "package",
|
||||
|
@ -238,13 +239,6 @@ class MetadataTestCase(support.TempdirManager, unittest.TestCase):
|
|||
def test_custom_pydistutils(self):
|
||||
# fixes #2166
|
||||
# make sure pydistutils.cfg is found
|
||||
old = {}
|
||||
for env in ('HOME', 'HOMEPATH', 'HOMEDRIVE'):
|
||||
value = os.environ.get(env)
|
||||
old[env] = value
|
||||
if value is not None:
|
||||
del os.environ[env]
|
||||
|
||||
if os.name == 'posix':
|
||||
user_filename = ".pydistutils.cfg"
|
||||
else:
|
||||
|
@ -261,22 +255,18 @@ class MetadataTestCase(support.TempdirManager, unittest.TestCase):
|
|||
|
||||
# linux-style
|
||||
if sys.platform in ('linux', 'darwin'):
|
||||
os.environ['HOME'] = temp_dir
|
||||
self.environ['HOME'] = temp_dir
|
||||
files = dist.find_config_files()
|
||||
self.assert_(user_filename in files)
|
||||
|
||||
# win32-style
|
||||
if sys.platform == 'win32':
|
||||
# home drive should be found
|
||||
os.environ['HOME'] = temp_dir
|
||||
self.environ['HOME'] = temp_dir
|
||||
files = dist.find_config_files()
|
||||
self.assert_(user_filename in files,
|
||||
'%r not found in %r' % (user_filename, files))
|
||||
finally:
|
||||
for key, value in old.items():
|
||||
if value is None:
|
||||
continue
|
||||
os.environ[key] = value
|
||||
os.remove(user_filename)
|
||||
|
||||
def test_suite():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue