diff options
Diffstat (limited to 'Lib/distutils/tests/test_config.py')
-rw-r--r-- | Lib/distutils/tests/test_config.py | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/Lib/distutils/tests/test_config.py b/Lib/distutils/tests/test_config.py index 7737538..fd778d1 100644 --- a/Lib/distutils/tests/test_config.py +++ b/Lib/distutils/tests/test_config.py @@ -49,18 +49,14 @@ password:xxx class PyPIRCCommandTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): """Patches the environment.""" super(PyPIRCCommandTestCase, self).setUp() - - if os.environ.has_key('HOME'): - self._old_home = os.environ['HOME'] - else: - self._old_home = None self.tmp_dir = self.mkdtemp() - os.environ['HOME'] = self.tmp_dir + self.environ['HOME'] = self.tmp_dir self.rc = os.path.join(self.tmp_dir, '.pypirc') self.dist = Distribution() @@ -76,10 +72,6 @@ class PyPIRCCommandTestCase(support.TempdirManager, def tearDown(self): """Removes the patch.""" - if self._old_home is None: - del os.environ['HOME'] - else: - os.environ['HOME'] = self._old_home set_threshold(self.old_threshold) super(PyPIRCCommandTestCase, self).tearDown() @@ -89,12 +81,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, # 2. handle the old format # new format - f = open(self.rc, 'w') - try: - f.write(PYPIRC) - finally: - f.close() - + self.write_file(self.rc, PYPIRC) cmd = self._cmd(self.dist) config = cmd._read_pypirc() @@ -106,10 +93,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, self.assertEquals(config, waited) # old format - f = open(self.rc, 'w') - f.write(PYPIRC_OLD) - f.close() - + self.write_file(self.rc, PYPIRC_OLD) config = cmd._read_pypirc() config = config.items() config.sort() @@ -119,19 +103,14 @@ class PyPIRCCommandTestCase(support.TempdirManager, self.assertEquals(config, waited) def test_server_empty_registration(self): - cmd = self._cmd(self.dist) rc = cmd._get_rc_file() self.assert_(not os.path.exists(rc)) - cmd._store_pypirc('tarek', 'xxx') - self.assert_(os.path.exists(rc)) content = open(rc).read() - self.assertEquals(content, WANTED) - def test_suite(): return unittest.makeSuite(PyPIRCCommandTestCase) |