2009-05-10 09:02:35 -03:00
|
|
|
"""Tests for distutils.sysconfig."""
|
2007-12-08 11:34:59 -04:00
|
|
|
import os
|
2009-06-11 05:31:17 -03:00
|
|
|
import test
|
2007-12-08 11:34:59 -04:00
|
|
|
import unittest
|
Merged revisions 78018,78035-78040,78042-78043,78046,78048-78052,78054,78059,78075-78080 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78018 | georg.brandl | 2010-02-06 11:08:21 +0100 (Sa, 06 Feb 2010) | 1 line
#7864: make deprecation notices a bit clearer.
........
r78035 | georg.brandl | 2010-02-06 23:44:17 +0100 (Sa, 06 Feb 2010) | 1 line
Fix duplicate import.
........
r78036 | georg.brandl | 2010-02-06 23:49:47 +0100 (Sa, 06 Feb 2010) | 1 line
Remove unused import.
........
r78037 | georg.brandl | 2010-02-06 23:59:15 +0100 (Sa, 06 Feb 2010) | 1 line
No need to assign the results of expressions used only for side effects.
........
r78038 | georg.brandl | 2010-02-07 00:02:29 +0100 (So, 07 Feb 2010) | 1 line
Add a missing import.
........
r78039 | georg.brandl | 2010-02-07 00:06:24 +0100 (So, 07 Feb 2010) | 1 line
Add missing imports.
........
r78040 | georg.brandl | 2010-02-07 00:08:00 +0100 (So, 07 Feb 2010) | 1 line
Fix a few UnboundLocalErrors in test_long.
........
r78042 | georg.brandl | 2010-02-07 00:12:12 +0100 (So, 07 Feb 2010) | 1 line
Add missing import.
........
r78043 | georg.brandl | 2010-02-07 00:12:19 +0100 (So, 07 Feb 2010) | 1 line
Remove duplicate test method.
........
r78046 | georg.brandl | 2010-02-07 00:18:00 +0100 (So, 07 Feb 2010) | 1 line
Fix various missing import/unbound name errors.
........
r78048 | georg.brandl | 2010-02-07 00:23:45 +0100 (So, 07 Feb 2010) | 1 line
We heard you like test failures so we put unbound locals in your test so that you can fail while you fail.
........
r78049 | georg.brandl | 2010-02-07 00:33:33 +0100 (So, 07 Feb 2010) | 1 line
Fix import/access for some identifiers. _TestSharedCTypes does not seem to be executed?
........
r78050 | georg.brandl | 2010-02-07 00:34:10 +0100 (So, 07 Feb 2010) | 1 line
Fix more unbound locals in code paths that do not seem to be used.
........
r78051 | georg.brandl | 2010-02-07 00:53:52 +0100 (So, 07 Feb 2010) | 1 line
Add missing import when running these tests standalone.
........
r78052 | georg.brandl | 2010-02-07 00:54:04 +0100 (So, 07 Feb 2010) | 1 line
Add missing import when running these tests standalone.
........
r78054 | georg.brandl | 2010-02-07 00:58:25 +0100 (So, 07 Feb 2010) | 1 line
Add missing import.
........
r78059 | georg.brandl | 2010-02-07 12:34:15 +0100 (So, 07 Feb 2010) | 1 line
Use "regexp" consistently.
........
r78075 | georg.brandl | 2010-02-07 13:16:12 +0100 (So, 07 Feb 2010) | 1 line
Fix another duplicated test method.
........
r78076 | georg.brandl | 2010-02-07 13:19:43 +0100 (So, 07 Feb 2010) | 1 line
Fix wrong usage of "except X, Y:".
........
r78077 | georg.brandl | 2010-02-07 13:25:50 +0100 (So, 07 Feb 2010) | 1 line
Fix two redefined test methods.
........
r78078 | georg.brandl | 2010-02-07 13:27:06 +0100 (So, 07 Feb 2010) | 1 line
Fix a redefined test method.
........
r78079 | georg.brandl | 2010-02-07 13:34:26 +0100 (So, 07 Feb 2010) | 1 line
Add a minimal test for fnmatchcase().
........
r78080 | georg.brandl | 2010-02-07 13:55:12 +0100 (So, 07 Feb 2010) | 1 line
Remove duplicate test method.
........
2010-03-14 07:23:39 -03:00
|
|
|
import shutil
|
2007-12-08 11:34:59 -04:00
|
|
|
|
2009-05-10 09:02:35 -03:00
|
|
|
from distutils import sysconfig
|
|
|
|
from distutils.tests import support
|
2009-06-11 05:31:17 -03:00
|
|
|
from test.support import TESTFN, run_unittest
|
2007-12-08 11:34:59 -04:00
|
|
|
|
2009-05-10 09:02:35 -03:00
|
|
|
class SysconfigTestCase(support.EnvironGuard,
|
|
|
|
unittest.TestCase):
|
2009-06-11 05:31:17 -03:00
|
|
|
def setUp(self):
|
|
|
|
super(SysconfigTestCase, self).setUp()
|
|
|
|
self.makefile = None
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
if self.makefile is not None:
|
|
|
|
os.unlink(self.makefile)
|
2009-10-18 08:34:51 -03:00
|
|
|
self.cleanup_testfn()
|
2009-06-11 05:31:17 -03:00
|
|
|
super(SysconfigTestCase, self).tearDown()
|
2009-02-05 21:18:36 -04:00
|
|
|
|
2009-10-18 08:34:51 -03:00
|
|
|
def cleanup_testfn(self):
|
|
|
|
if os.path.isfile(TESTFN):
|
|
|
|
os.remove(TESTFN)
|
|
|
|
elif os.path.isdir(TESTFN):
|
|
|
|
shutil.rmtree(TESTFN)
|
|
|
|
|
2010-01-29 07:41:03 -04:00
|
|
|
@support.capture_warnings
|
2007-12-08 11:34:59 -04:00
|
|
|
def test_get_python_lib(self):
|
|
|
|
lib_dir = sysconfig.get_python_lib()
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-14 21:27:15 -04:00
|
|
|
# XXX doesn't work on Linux when Python was never installed before
|
2009-06-30 20:06:06 -03:00
|
|
|
#self.assertTrue(os.path.isdir(lib_dir), lib_dir)
|
2007-12-08 11:34:59 -04:00
|
|
|
# test for pythonxx.lib?
|
2009-02-10 08:36:33 -04:00
|
|
|
self.assertNotEqual(sysconfig.get_python_lib(),
|
|
|
|
sysconfig.get_python_lib(prefix=TESTFN))
|
2010-01-29 07:41:03 -04:00
|
|
|
_sysconfig = __import__('sysconfig')
|
|
|
|
res = sysconfig.get_python_lib(True, True)
|
|
|
|
self.assertEquals(_sysconfig.get_path('platstdlib'), res)
|
2007-12-08 11:34:59 -04:00
|
|
|
|
2010-01-29 07:41:03 -04:00
|
|
|
@support.capture_warnings
|
2007-12-08 11:34:59 -04:00
|
|
|
def test_get_python_inc(self):
|
2009-02-05 12:35:04 -04:00
|
|
|
inc_dir = sysconfig.get_python_inc()
|
|
|
|
# This is not much of a test. We make sure Python.h exists
|
|
|
|
# in the directory returned by get_python_inc() but we don't know
|
|
|
|
# it is the correct file.
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertTrue(os.path.isdir(inc_dir), inc_dir)
|
2007-12-08 11:34:59 -04:00
|
|
|
python_h = os.path.join(inc_dir, "Python.h")
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertTrue(os.path.isfile(python_h), python_h)
|
2007-12-08 11:34:59 -04:00
|
|
|
|
2010-01-29 07:41:03 -04:00
|
|
|
@support.capture_warnings
|
2009-06-11 05:31:17 -03:00
|
|
|
def test_parse_makefile_base(self):
|
|
|
|
self.makefile = TESTFN
|
|
|
|
fd = open(self.makefile, 'w')
|
|
|
|
fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'" '\n')
|
|
|
|
fd.write('VAR=$OTHER\nOTHER=foo')
|
|
|
|
fd.close()
|
|
|
|
d = sysconfig.parse_makefile(self.makefile)
|
|
|
|
self.assertEquals(d, {'CONFIG_ARGS': "'--arg1=optarg1' 'ENV=LIB'",
|
|
|
|
'OTHER': 'foo'})
|
|
|
|
|
|
|
|
def test_parse_makefile_literal_dollar(self):
|
|
|
|
self.makefile = TESTFN
|
|
|
|
fd = open(self.makefile, 'w')
|
|
|
|
fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=\$$LIB'" '\n')
|
|
|
|
fd.write('VAR=$OTHER\nOTHER=foo')
|
|
|
|
fd.close()
|
|
|
|
d = sysconfig.parse_makefile(self.makefile)
|
|
|
|
self.assertEquals(d, {'CONFIG_ARGS': r"'--arg1=optarg1' 'ENV=\$LIB'",
|
|
|
|
'OTHER': 'foo'})
|
|
|
|
|
2007-12-08 11:34:59 -04:00
|
|
|
|
|
|
|
def test_suite():
|
|
|
|
suite = unittest.TestSuite()
|
|
|
|
suite.addTest(unittest.makeSuite(SysconfigTestCase))
|
|
|
|
return suite
|
2009-06-11 05:31:17 -03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
run_unittest(test_suite())
|