summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/test_config.py
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-02-14 14:10:23 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-02-14 14:10:23 (GMT)
commit1369900619d943d05342e7b781f1f3fb45ece4c9 (patch)
treef63793c2c87853e3bf59509f90c0edb2368ba2bf /Lib/distutils/tests/test_config.py
parenta4038038c69c72f96f1c7d435d50818c46892591 (diff)
downloadcpython-1369900619d943d05342e7b781f1f3fb45ece4c9.zip
cpython-1369900619d943d05342e7b781f1f3fb45ece4c9.tar.gz
cpython-1369900619d943d05342e7b781f1f3fb45ece4c9.tar.bz2
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Diffstat (limited to 'Lib/distutils/tests/test_config.py')
-rw-r--r--Lib/distutils/tests/test_config.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/distutils/tests/test_config.py b/Lib/distutils/tests/test_config.py
index cae7689..d812769 100644
--- a/Lib/distutils/tests/test_config.py
+++ b/Lib/distutils/tests/test_config.py
@@ -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: