summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-05 16:25:16 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-05 16:25:16 (GMT)
commita52f1c62eb8cce9fb7f78687b854d1d8c4dbe39f (patch)
tree0b4fbee0cc22f2e6040f9b0ab6579223736ada7f
parente844be6d9aba1c19c929d3550f71c2d530175e62 (diff)
downloadcpython-a52f1c62eb8cce9fb7f78687b854d1d8c4dbe39f.zip
cpython-a52f1c62eb8cce9fb7f78687b854d1d8c4dbe39f.tar.gz
cpython-a52f1c62eb8cce9fb7f78687b854d1d8c4dbe39f.tar.bz2
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.
-rw-r--r--Lib/distutils/tests/test_build_ext.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 31b8b48..b268820 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -11,6 +11,10 @@ from distutils import sysconfig
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 @@ class BuildExtTestCase(unittest.TestCase):
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 @@ class BuildExtTestCase(unittest.TestCase):
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)