summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2011-06-28 07:42:50 (GMT)
committerNed Deily <nad@acm.org>2011-06-28 07:42:50 (GMT)
commit58f27b203c34ec81a14a8d73ce1d5fc5350946a9 (patch)
tree8749a987f5d50858edfd88186cae245e48c76043 /Lib/distutils
parent3eb67d58d61cec42c09242a7d801072c3e448dcf (diff)
downloadcpython-58f27b203c34ec81a14a8d73ce1d5fc5350946a9.zip
cpython-58f27b203c34ec81a14a8d73ce1d5fc5350946a9.tar.gz
cpython-58f27b203c34ec81a14a8d73ce1d5fc5350946a9.tar.bz2
Issue #12141: Install a copy of template C module file so that
test_build_ext of test_distutils is no longer silently skipped when run outside of a build directory.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/tests/test_build_ext.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 0aa99ba..d924f58 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -22,6 +22,11 @@ from test.support import run_unittest
ALREADY_TESTED = False
def _get_source_filename():
+ # use installed copy if available
+ tests_f = os.path.join(os.path.dirname(__file__), 'xxmodule.c')
+ if os.path.exists(tests_f):
+ return tests_f
+ # otherwise try using copy from build directory
srcdir = sysconfig.get_config_var('srcdir')
return os.path.join(srcdir, 'Modules', 'xxmodule.c')
@@ -35,7 +40,9 @@ class BuildExtTestCase(TempdirManager,
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)
+ filename = _get_source_filename()
+ if os.path.exists(filename):
+ shutil.copy(filename, self.tmp_dir)
if sys.version > "2.6":
import site
self.old_user_base = site.USER_BASE
@@ -65,6 +72,8 @@ class BuildExtTestCase(TempdirManager,
def test_build_ext(self):
global ALREADY_TESTED
xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
+ if not os.path.exists(xx_c):
+ return
xx_ext = Extension('xx', [xx_c])
dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
dist.package_dir = self.tmp_dir