Fix for #5257: refactored all tests in distutils, so they use a temporary directory.

This commit is contained in:
Tarek Ziadé 2009-02-14 14:10:23 +00:00
parent a4038038c6
commit 1369900619
8 changed files with 67 additions and 74 deletions

View file

@ -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 import support
import unittest
from test import test_support
@ -19,11 +20,12 @@ def _get_source_filename():
srcdir = sysconfig.get_config_var('srcdir')
return os.path.join(srcdir, 'Modules', 'xxmodule.c')
class BuildExtTestCase(unittest.TestCase):
class BuildExtTestCase(support.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_")
support.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 @@ def tearDown(self):
# Get everything back to normal
test_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')
support.TempdirManager.tearDown(self)
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})