[Python-checkins] r69304 - python/trunk/Lib/distutils/tests/test_build_ext.py
neil.schemenauer
python-checkins at python.org
Thu Feb 5 17:25:16 CET 2009
Author: neil.schemenauer
Date: Thu Feb 5 17:25:16 2009
New Revision: 69304
Log:
Fix test_build_ext.py to work when building in a separate directory.
Since "srcdir" should now be defined on all platforms, use it to
find the module source.
Modified:
python/trunk/Lib/distutils/tests/test_build_ext.py
Modified: python/trunk/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/trunk/Lib/distutils/tests/test_build_ext.py (original)
+++ python/trunk/Lib/distutils/tests/test_build_ext.py Thu Feb 5 17:25:16 2009
@@ -11,6 +11,10 @@
import unittest
from test import test_support
+def _get_source_filename():
+ srcdir = sysconfig.get_config_var('srcdir')
+ return os.path.join(srcdir, 'Modules', 'xxmodule.c')
+
class BuildExtTestCase(unittest.TestCase):
def setUp(self):
# Create a simple test environment
@@ -18,9 +22,7 @@
self.tmp_dir = tempfile.mkdtemp(prefix="pythontest_")
self.sys_path = sys.path[:]
sys.path.append(self.tmp_dir)
-
- xx_c = os.path.join(sysconfig.project_base, 'Modules', 'xxmodule.c')
- shutil.copy(xx_c, self.tmp_dir)
+ shutil.copy(_get_source_filename(), self.tmp_dir)
def test_build_ext(self):
xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
@@ -66,9 +68,11 @@
shutil.rmtree(self.tmp_dir, os.name == 'nt' or sys.platform == 'cygwin')
def test_suite():
- if not sysconfig.python_build:
+ src = _get_source_filename()
+ if not os.path.exists(src):
if test_support.verbose:
- print 'test_build_ext: The test must be run in a python build dir'
+ print ('test_build_ext: Cannot find source code (test'
+ ' must run in python build dir)')
return unittest.TestSuite()
else: return unittest.makeSuite(BuildExtTestCase)
More information about the Python-checkins
mailing list