|
1 """Tests for distutils.dist.""" |
|
2 |
|
3 from distutils import sysconfig |
|
4 import os |
|
5 import unittest |
|
6 |
|
7 from test.test_support import TESTFN |
|
8 |
|
9 class SysconfigTestCase(unittest.TestCase): |
|
10 |
|
11 def test_get_config_h_filename(self): |
|
12 config_h = sysconfig.get_config_h_filename() |
|
13 self.assert_(os.path.isfile(config_h), config_h) |
|
14 |
|
15 def test_get_python_lib(self): |
|
16 lib_dir = sysconfig.get_python_lib() |
|
17 # XXX doesn't work on Linux when Python was never installed before |
|
18 #self.assert_(os.path.isdir(lib_dir), lib_dir) |
|
19 # test for pythonxx.lib? |
|
20 |
|
21 def test_get_python_inc(self): |
|
22 # The check for srcdir is copied from Python's setup.py, |
|
23 # and is necessary to make this test pass when building |
|
24 # Python in a directory other than the source directory. |
|
25 (srcdir,) = sysconfig.get_config_vars('srcdir') |
|
26 if not srcdir: |
|
27 inc_dir = sysconfig.get_python_inc() |
|
28 else: |
|
29 # This test is not really a proper test: when building |
|
30 # Python from source, even in the same directory, |
|
31 # we won't be testing the same thing as when running |
|
32 # distutils' tests on an installed Python. Nevertheless, |
|
33 # let's try to do our best: if we are running Python's |
|
34 # unittests from a build directory that is not the source |
|
35 # directory, the normal inc_dir will exist, it will just not |
|
36 # contain anything of interest. |
|
37 inc_dir = sysconfig.get_python_inc() |
|
38 self.assert_(os.path.isdir(inc_dir)) |
|
39 # Now test the source location, to make sure Python.h does |
|
40 # exist. |
|
41 inc_dir = os.path.join(os.getcwd(), srcdir, 'Include') |
|
42 inc_dir = os.path.normpath(inc_dir) |
|
43 self.assert_(os.path.isdir(inc_dir), inc_dir) |
|
44 python_h = os.path.join(inc_dir, "Python.h") |
|
45 self.assert_(os.path.isfile(python_h), python_h) |
|
46 |
|
47 def test_get_config_vars(self): |
|
48 cvars = sysconfig.get_config_vars() |
|
49 self.assert_(isinstance(cvars, dict)) |
|
50 self.assert_(cvars) |
|
51 |
|
52 |
|
53 def test_suite(): |
|
54 suite = unittest.TestSuite() |
|
55 suite.addTest(unittest.makeSuite(SysconfigTestCase)) |
|
56 return suite |