11"""Tests for distutils.sysconfig."""
22import os
33import shutil
4- import test
54import unittest
65
76from distutils import sysconfig
87from distutils .ccompiler import get_default_compiler
98from distutils .tests import support
109from test .support import TESTFN , run_unittest
1110
12- class SysconfigTestCase (support .EnvironGuard ,
13- unittest .TestCase ):
11+ class SysconfigTestCase (support .EnvironGuard , unittest .TestCase ):
1412 def setUp (self ):
1513 super (SysconfigTestCase , self ).setUp ()
1614 self .makefile = None
@@ -32,7 +30,6 @@ def test_get_config_h_filename(self):
3230 self .assertTrue (os .path .isfile (config_h ), config_h )
3331
3432 def test_get_python_lib (self ):
35- lib_dir = sysconfig .get_python_lib ()
3633 # XXX doesn't work on Linux when Python was never installed before
3734 #self.assertTrue(os.path.isdir(lib_dir), lib_dir)
3835 # test for pythonxx.lib?
@@ -67,8 +64,9 @@ def test_srcdir(self):
6764 self .assertTrue (os .path .exists (Python_h ), Python_h )
6865 self .assertTrue (sysconfig ._is_python_source_dir (srcdir ))
6966 elif os .name == 'posix' :
70- self .assertEqual (os .path .dirname (sysconfig .get_makefile_filename ()),
71- srcdir )
67+ self .assertEqual (
68+ os .path .dirname (sysconfig .get_makefile_filename ()),
69+ srcdir )
7270
7371 def test_srcdir_independent_of_cwd (self ):
7472 # srcdir should be independent of the current working directory
@@ -129,10 +127,13 @@ def test_parse_makefile_literal_dollar(self):
129127
130128 def test_sysconfig_module (self ):
131129 import sysconfig as global_sysconfig
132- self .assertEqual (global_sysconfig .get_config_var ('CFLAGS' ), sysconfig .get_config_var ('CFLAGS' ))
133- self .assertEqual (global_sysconfig .get_config_var ('LDFLAGS' ), sysconfig .get_config_var ('LDFLAGS' ))
130+ self .assertEqual (global_sysconfig .get_config_var ('CFLAGS' ),
131+ sysconfig .get_config_var ('CFLAGS' ))
132+ self .assertEqual (global_sysconfig .get_config_var ('LDFLAGS' ),
133+ sysconfig .get_config_var ('LDFLAGS' ))
134134
135- @unittest .skipIf (sysconfig .get_config_var ('CUSTOMIZED_OSX_COMPILER' ),'compiler flags customized' )
135+ @unittest .skipIf (sysconfig .get_config_var ('CUSTOMIZED_OSX_COMPILER' ),
136+ 'compiler flags customized' )
136137 def test_sysconfig_compiler_vars (self ):
137138 # On OS X, binary installers support extension module building on
138139 # various levels of the operating system with differing Xcode
@@ -151,9 +152,29 @@ def test_sysconfig_compiler_vars(self):
151152 import sysconfig as global_sysconfig
152153 if sysconfig .get_config_var ('CUSTOMIZED_OSX_COMPILER' ):
153154 return
154- self .assertEqual (global_sysconfig .get_config_var ('LDSHARED' ), sysconfig .get_config_var ('LDSHARED' ))
155- self .assertEqual (global_sysconfig .get_config_var ('CC' ), sysconfig .get_config_var ('CC' ))
156-
155+ self .assertEqual (global_sysconfig .get_config_var ('LDSHARED' ),
156+ sysconfig .get_config_var ('LDSHARED' ))
157+ self .assertEqual (global_sysconfig .get_config_var ('CC' ),
158+ sysconfig .get_config_var ('CC' ))
159+
160+ @unittest .skipIf (sysconfig .get_config_var ('EXT_SUFFIX' ) is None ,
161+ 'EXT_SUFFIX required for this test' )
162+ def test_SO_deprecation (self ):
163+ self .assertWarns (DeprecationWarning ,
164+ sysconfig .get_config_var , 'SO' )
165+
166+ @unittest .skipIf (sysconfig .get_config_var ('EXT_SUFFIX' ) is None ,
167+ 'EXT_SUFFIX required for this test' )
168+ def test_SO_value (self ):
169+ self .assertEqual (sysconfig .get_config_var ('SO' ),
170+ sysconfig .get_config_var ('EXT_SUFFIX' ))
171+
172+ @unittest .skipIf (sysconfig .get_config_var ('EXT_SUFFIX' ) is None ,
173+ 'EXT_SUFFIX required for this test' )
174+ def test_SO_in_vars (self ):
175+ vars = sysconfig .get_config_vars ()
176+ self .assertIsNotNone (vars ['SO' ])
177+ self .assertEqual (vars ['SO' ], vars ['EXT_SUFFIX' ])
157178
158179
159180def test_suite ():
0 commit comments