Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/tests/test_sysconfig.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 1bec64b8dd17 |
| children | 65793acc0095 |
| rev | line source |
|---|---|
|
53976
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
1 """Tests for distutils.sysconfig.""" |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
2 import os |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
3 import unittest |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
4 |
|
53976
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
5 from distutils import sysconfig |
|
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
6 from distutils.ccompiler import get_default_compiler |
|
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
7 from distutils.tests import support |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
8 from test.test_support import TESTFN |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
9 |
|
53976
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
10 class SysconfigTestCase(support.EnvironGuard, |
|
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
11 unittest.TestCase): |
|
51374
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
12 |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
13 def test_get_config_h_filename(self): |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
14 config_h = sysconfig.get_config_h_filename() |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
15 self.assert_(os.path.isfile(config_h), config_h) |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
16 |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
17 def test_get_python_lib(self): |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
18 lib_dir = sysconfig.get_python_lib() |
| 44308 | 19 # XXX doesn't work on Linux when Python was never installed before |
|
44201
74bdd50f07e5
Disabled one test that is failing on Unix
Christian Heimes <christian@cheimes.de>
parents:
44198
diff
changeset
|
20 #self.assert_(os.path.isdir(lib_dir), lib_dir) |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
21 # test for pythonxx.lib? |
|
51504
c61f24ff055e
Fixed #3386: the optional prefix argument was ignored under OS2 and NT in distutils.sysconfig.get_python_lib
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51397
diff
changeset
|
22 self.assertNotEqual(sysconfig.get_python_lib(), |
|
c61f24ff055e
Fixed #3386: the optional prefix argument was ignored under OS2 and NT in distutils.sysconfig.get_python_lib
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51397
diff
changeset
|
23 sysconfig.get_python_lib(prefix=TESTFN)) |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
24 |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
25 def test_get_python_inc(self): |
|
51344
bf3b8e30213f
Since sysconfig.get_python_inc() now works when building in a
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
46319
diff
changeset
|
26 inc_dir = sysconfig.get_python_inc() |
|
bf3b8e30213f
Since sysconfig.get_python_inc() now works when building in a
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
46319
diff
changeset
|
27 # This is not much of a test. We make sure Python.h exists |
|
bf3b8e30213f
Since sysconfig.get_python_inc() now works when building in a
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
46319
diff
changeset
|
28 # in the directory returned by get_python_inc() but we don't know |
|
bf3b8e30213f
Since sysconfig.get_python_inc() now works when building in a
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
46319
diff
changeset
|
29 # it is the correct file. |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
30 self.assert_(os.path.isdir(inc_dir), inc_dir) |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
31 python_h = os.path.join(inc_dir, "Python.h") |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
32 self.assert_(os.path.isfile(python_h), python_h) |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
33 |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
34 def test_get_config_vars(self): |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
35 cvars = sysconfig.get_config_vars() |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
36 self.assert_(isinstance(cvars, dict)) |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
37 self.assert_(cvars) |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
38 |
|
51374
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
39 def test_customize_compiler(self): |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
40 |
|
51397
c9affba069ea
Fixed #5167: test_customize_compiler does not apply under non unix compilers
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51374
diff
changeset
|
41 # not testing if default compiler is not unix |
|
c9affba069ea
Fixed #5167: test_customize_compiler does not apply under non unix compilers
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51374
diff
changeset
|
42 if get_default_compiler() != 'unix': |
|
c9affba069ea
Fixed #5167: test_customize_compiler does not apply under non unix compilers
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51374
diff
changeset
|
43 return |
|
c9affba069ea
Fixed #5167: test_customize_compiler does not apply under non unix compilers
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51374
diff
changeset
|
44 |
|
53976
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
45 self.environ['AR'] = 'my_ar' |
|
1bec64b8dd17
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53897
diff
changeset
|
46 self.environ['ARFLAGS'] = '-arflags' |
|
51374
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
47 |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
48 # make sure AR gets caught |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
49 class compiler: |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
50 compiler_type = 'unix' |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
51 |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
52 def set_executables(self, **kw): |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
53 self.exes = kw |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
54 |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
55 comp = compiler() |
|
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
56 sysconfig.customize_compiler(comp) |
|
53888
9143d20d8b26
Fixed #5941: added ARFLAGS for the archiver command.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51504
diff
changeset
|
57 self.assertEquals(comp.exes['archiver'], 'my_ar -arflags') |
|
51374
fdecb9182604
fixed #1520877: now distutils reads Read from the environment/Makefile
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51344
diff
changeset
|
58 |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
59 |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
60 def test_suite(): |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
61 suite = unittest.TestSuite() |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
62 suite.addTest(unittest.makeSuite(SysconfigTestCase)) |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
63 return suite |
