diff -r 5abea8a43f19 Lib/distutils/tests/test_build_ext.py --- a/Lib/distutils/tests/test_build_ext.py Sun Aug 05 18:20:17 2012 +1000 +++ b/Lib/distutils/tests/test_build_ext.py Sun Aug 05 22:40:42 2012 +1200 @@ -15,6 +15,7 @@ import unittest from test import support +import shutil # http://bugs.python.org/issue4373 # Don't load the xx module more than once. @@ -66,7 +67,9 @@ ALREADY_TESTED = True import xx + self._check_module(xx) + def _check_module(self, xx): for attr in ('error', 'foo', 'new', 'roj'): self.assertTrue(hasattr(xx, attr)) @@ -78,6 +81,32 @@ self.assertTrue(isinstance(xx.Null(), xx.Null)) self.assertTrue(isinstance(xx.Str(), xx.Str)) + def test_build_ext_with_space(self): + # Test building an extension with spaces in the path. + copy_xxmodule_c(self.tmp_dir) + xx_c = os.path.join(self.tmp_dir, 'xxmodule.c') + spaced_xx_c = os.path.join(self.tmp_dir, 'xx module.c') + shutil.move(xx_c, spaced_xx_c) + xx_ext = Extension('xx', [spaced_xx_c]) + dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]}) + dist.package_dir = self.tmp_dir + cmd = build_ext(dist) + fixup_build_ext(cmd) + cmd.build_lib = self.tmp_dir + cmd.build_temp = self.tmp_dir + + old_stdout = sys.stdout + if not support.verbose: + # silence compiler output + sys.stdout = StringIO() + try: + cmd.ensure_finalized() + cmd.run() + finally: + sys.stdout = old_stdout + import xx + self._check_module(xx) + def tearDown(self): # Get everything back to normal support.unload('xx') @@ -356,9 +385,6 @@ def test_ext_fullpath(self): ext = sysconfig.get_config_vars()['SO'] # building lxml.etree inplace - #etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c') - #etree_ext = Extension('lxml.etree', [etree_c]) - #dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]}) dist = Distribution() cmd = build_ext(dist) cmd.inplace = 1