+++ /dev/null
-"""Tests for distutils.sysconfig."""\r
-import os\r
-import test\r
-import unittest\r
-import shutil\r
-\r
-from distutils import sysconfig\r
-from distutils.tests import support\r
-from test.test_support import TESTFN\r
-\r
-class SysconfigTestCase(support.EnvironGuard,\r
- unittest.TestCase):\r
- def setUp(self):\r
- super(SysconfigTestCase, self).setUp()\r
- self.makefile = None\r
-\r
- def tearDown(self):\r
- if self.makefile is not None:\r
- os.unlink(self.makefile)\r
- self.cleanup_testfn()\r
- super(SysconfigTestCase, self).tearDown()\r
-\r
- def cleanup_testfn(self):\r
- path = test.test_support.TESTFN\r
- if os.path.isfile(path):\r
- os.remove(path)\r
- elif os.path.isdir(path):\r
- shutil.rmtree(path)\r
-\r
- def test_get_python_lib(self):\r
- lib_dir = sysconfig.get_python_lib()\r
- # XXX doesn't work on Linux when Python was never installed before\r
- #self.assertTrue(os.path.isdir(lib_dir), lib_dir)\r
- # test for pythonxx.lib?\r
- self.assertNotEqual(sysconfig.get_python_lib(),\r
- sysconfig.get_python_lib(prefix=TESTFN))\r
- _sysconfig = __import__('sysconfig')\r
- res = sysconfig.get_python_lib(True, True)\r
- self.assertEqual(_sysconfig.get_path('platstdlib'), res)\r
-\r
- def test_get_python_inc(self):\r
- inc_dir = sysconfig.get_python_inc()\r
- # This is not much of a test. We make sure Python.h exists\r
- # in the directory returned by get_python_inc() but we don't know\r
- # it is the correct file.\r
- self.assertTrue(os.path.isdir(inc_dir), inc_dir)\r
- python_h = os.path.join(inc_dir, "Python.h")\r
- self.assertTrue(os.path.isfile(python_h), python_h)\r
-\r
- def test_parse_makefile_base(self):\r
- self.makefile = test.test_support.TESTFN\r
- fd = open(self.makefile, 'w')\r
- try:\r
- fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'" '\n')\r
- fd.write('VAR=$OTHER\nOTHER=foo')\r
- finally:\r
- fd.close()\r
- d = sysconfig.parse_makefile(self.makefile)\r
- self.assertEqual(d, {'CONFIG_ARGS': "'--arg1=optarg1' 'ENV=LIB'",\r
- 'OTHER': 'foo'})\r
-\r
- def test_parse_makefile_literal_dollar(self):\r
- self.makefile = test.test_support.TESTFN\r
- fd = open(self.makefile, 'w')\r
- try:\r
- fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=\$$LIB'" '\n')\r
- fd.write('VAR=$OTHER\nOTHER=foo')\r
- finally:\r
- fd.close()\r
- d = sysconfig.parse_makefile(self.makefile)\r
- self.assertEqual(d, {'CONFIG_ARGS': r"'--arg1=optarg1' 'ENV=\$LIB'",\r
- 'OTHER': 'foo'})\r
-\r
-\r
-def test_suite():\r
- suite = unittest.TestSuite()\r
- suite.addTest(unittest.makeSuite(SysconfigTestCase))\r
- return suite\r
-\r
-\r
-if __name__ == '__main__':\r
- test.test_support.run_unittest(test_suite())\r