diff options
author | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-10-18 11:34:51 (GMT) |
---|---|---|
committer | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-10-18 11:34:51 (GMT) |
commit | 430fb63dd2c9bb0ed412fb61be1da9b130deab14 (patch) | |
tree | 3841e3454b6b02dfa0eb7d590222aef80c82b9af /Lib/distutils/tests/test_dist.py | |
parent | ccb3c0946c2140a3e5b0f04d137785c2ca1e071c (diff) | |
download | cpython-430fb63dd2c9bb0ed412fb61be1da9b130deab14.zip cpython-430fb63dd2c9bb0ed412fb61be1da9b130deab14.tar.gz cpython-430fb63dd2c9bb0ed412fb61be1da9b130deab14.tar.bz2 |
Merged revisions 75485 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75485 | tarek.ziade | 2009-10-18 11:28:26 +0200 (Sun, 18 Oct 2009) | 1 line
Changed distutils tests to avoid environment alteration
........
Diffstat (limited to 'Lib/distutils/tests/test_dist.py')
-rw-r--r-- | Lib/distutils/tests/test_dist.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py index 799b0c0..be1010c 100644 --- a/Lib/distutils/tests/test_dist.py +++ b/Lib/distutils/tests/test_dist.py @@ -38,15 +38,17 @@ class TestDistribution(Distribution): class DistributionTestCase(support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): super(DistributionTestCase, self).setUp() - self.argv = sys.argv[:] + self.argv = sys.argv, sys.argv[:] del sys.argv[1:] def tearDown(self): - sys.argv[:] = self.argv + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] super(DistributionTestCase, self).tearDown() def create_distribution(self, configfiles=()): @@ -181,6 +183,15 @@ class DistributionTestCase(support.LoggingSilencer, class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): + def setUp(self): + super(MetadataTestCase, self).setUp() + self.argv = sys.argv, sys.argv[:] + + def tearDown(self): + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] + super(MetadataTestCase, self).tearDown() + def test_simple_metadata(self): attrs = {"name": "package", "version": "1.0"} @@ -279,14 +290,14 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, # linux-style if sys.platform in ('linux', 'darwin'): - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files) # win32-style if sys.platform == 'win32': # home drive should be found - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files, '%r not found in %r' % (user_filename, files)) @@ -302,15 +313,11 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, def test_show_help(self): # smoke test, just makes sure some help is displayed dist = Distribution() - old_argv = sys.argv sys.argv = [] - try: - dist.help = 1 - dist.script_name = 'setup.py' - with captured_stdout() as s: - dist.parse_command_line() - finally: - sys.argv = old_argv + dist.help = 1 + dist.script_name = 'setup.py' + with captured_stdout() as s: + dist.parse_command_line() output = [line for line in s.getvalue().split('\n') if line.strip() != ''] |