summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/test_build_ext.py
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-06 21:42:05 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-06 21:42:05 (GMT)
commitd8f63bbce50c702086cc93ea2131c268752d45b3 (patch)
treee0d344fc0524baf840c09e596148862bc08c45c2 /Lib/distutils/tests/test_build_ext.py
parent0a7b2c7bc393aee46081fe566ebd3edf0e8d5073 (diff)
downloadcpython-d8f63bbce50c702086cc93ea2131c268752d45b3.zip
cpython-d8f63bbce50c702086cc93ea2131c268752d45b3.tar.gz
cpython-d8f63bbce50c702086cc93ea2131c268752d45b3.tar.bz2
Make test_build_ext.py use sysconfig "srcdir" to find the source for
xxmodule.c. Have sysconfig make the srcdir path absolute if that seems necessary (running non-installed Python outside the build directory).
Diffstat (limited to 'Lib/distutils/tests/test_build_ext.py')
-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 4c57232..5e42943 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -15,6 +15,10 @@ from test import support
# Don't load the xx module more than once.
ALREADY_TESTED = False
+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
@@ -22,9 +26,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):
global ALREADY_TESTED
@@ -97,9 +99,11 @@ class BuildExtTestCase(unittest.TestCase):
self.assert_(len(cmd.library_dirs) > 0)
def test_suite():
- if not sysconfig.python_build:
+ src = _get_source_filename()
+ if not os.path.exists(src):
if 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)