Merged revisions 69609 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69609 | tarek.ziade | 2009-02-14 15:10:23 +0100 (Sat, 14 Feb 2009) | 1 line

  Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
........
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 5e42943..91b3de8 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -7,6 +7,7 @@
 from distutils.core import Extension, Distribution
 from distutils.command.build_ext import build_ext
 from distutils import sysconfig
+from distutils.tests.support import TempdirManager
 
 import unittest
 from test import support
@@ -19,11 +20,12 @@
     srcdir = sysconfig.get_config_var('srcdir')
     return os.path.join(srcdir, 'Modules', 'xxmodule.c')
 
-class BuildExtTestCase(unittest.TestCase):
+class BuildExtTestCase(TempdirManager, unittest.TestCase):
     def setUp(self):
         # Create a simple test environment
         # Note that we're making changes to sys.path
-        self.tmp_dir = tempfile.mkdtemp(prefix="pythontest_")
+        TempdirManager.setUp(self)
+        self.tmp_dir = self.mkdtemp()
         self.sys_path = sys.path[:]
         sys.path.append(self.tmp_dir)
         shutil.copy(_get_source_filename(), self.tmp_dir)
@@ -74,8 +76,7 @@
         # Get everything back to normal
         support.unload('xx')
         sys.path = self.sys_path
-        # XXX on Windows the test leaves a directory with xx module in TEMP
-        shutil.rmtree(self.tmp_dir, os.name == 'nt' or sys.platform == 'cygwin')
+        TempdirManager.tearDown(self)
 
     def test_solaris_enable_shared(self):
         dist = Distribution({'name': 'xx'})