[Python-checkins] r77955 - in python/branches/release26-maint: Lib/distutils/tests/test_build_ext.py

collin.winter python-checkins at python.org
Wed Feb 3 23:06:03 CET 2010


Author: collin.winter
Date: Wed Feb  3 23:06:03 2010
New Revision: 77955

Log:
Merged revisions 69304 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69304 | neil.schemenauer | 2009-02-05 08:25:16 -0800 (Thu, 05 Feb 2009) | 4 lines
  
  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/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py

Modified: python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py	(original)
+++ python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py	Wed Feb  3 23:06:03 2010
@@ -13,11 +13,14 @@
 import unittest
 from test import test_support
 
-
 # http://bugs.python.org/issue4373
 # 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(support.TempdirManager,
                        support.LoggingSilencer,
                        unittest.TestCase):
@@ -28,9 +31,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):
         global ALREADY_TESTED
@@ -387,9 +388,11 @@
         self.assertEquals(ext_path, wanted)
 
 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