[Python-checkins] r79621 - in python/branches/py3k: Lib/distutils/tests/test_build_ext.py
tarek.ziade
python-checkins at python.org
Fri Apr 2 23:24:55 CEST 2010
Author: tarek.ziade
Date: Fri Apr 2 23:24:55 2010
New Revision: 79621
Log:
Merged revisions 79618 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79618 | tarek.ziade | 2010-04-02 23:14:04 +0200 (Fri, 02 Apr 2010) | 1 line
removed the local copy of xxmodule, and skip only test_build_ext when xxmodule is not found, not the whole unittest
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/distutils/tests/test_build_ext.py
Modified: python/branches/py3k/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_ext.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_ext.py Fri Apr 2 23:24:55 2010
@@ -25,19 +25,23 @@
def _get_source_filename():
srcdir = sysconfig.get_config_var('srcdir')
+ if srcdir is None:
+ return os.path.join(sysconfig.project_base, 'Modules', 'xxmodule.c')
return os.path.join(srcdir, 'Modules', 'xxmodule.c')
-class BuildExtTestCase(TempdirManager,
- LoggingSilencer,
- unittest.TestCase):
+_XX_MODULE_PATH = _get_source_filename()
+
+class BuildExtTestCase(TempdirManager, LoggingSilencer, unittest.TestCase):
+
def setUp(self):
# Create a simple test environment
# Note that we're making changes to sys.path
super(BuildExtTestCase, self).setUp()
self.tmp_dir = self.mkdtemp()
- self.sys_path = sys.path, sys.path[:]
- sys.path.append(self.tmp_dir)
- shutil.copy(_get_source_filename(), self.tmp_dir)
+ if os.path.exists(_XX_MODULE_PATH):
+ self.sys_path = sys.path[:]
+ sys.path.append(self.tmp_dir)
+ shutil.copy(_XX_MODULE_PATH, self.tmp_dir)
if sys.version > "2.6":
import site
self.old_user_base = site.USER_BASE
@@ -45,6 +49,19 @@
from distutils.command import build_ext
build_ext.USER_BASE = site.USER_BASE
+ def tearDown(self):
+ # Get everything back to normal
+ if os.path.exists(_XX_MODULE_PATH):
+ 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')
+ super(BuildExtTestCase, self).tearDown()
+
+ @unittest.skipIf(not os.path.exists(_XX_MODULE_PATH),
+ 'xxmodule.c not found')
def test_build_ext(self):
global ALREADY_TESTED
xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
@@ -87,18 +104,6 @@
self.assertTrue(isinstance(xx.Null(), xx.Null))
self.assertTrue(isinstance(xx.Str(), xx.Str))
- def tearDown(self):
- # Get everything back to normal
- support.unload('xx')
- sys.path = self.sys_path[0]
- sys.path[:] = self.sys_path[1]
- if sys.version > "2.6":
- import site
- site.USER_BASE = self.old_user_base
- from distutils.command import build_ext
- build_ext.USER_BASE = self.old_user_base
- super(BuildExtTestCase, self).tearDown()
-
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
More information about the Python-checkins
mailing list