summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/test_sysconfig.py
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2012-07-27 11:06:55 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2012-07-27 11:06:55 (GMT)
commit46874ad367c2f3fdd47b2c8cb4b405bbcb2ed14a (patch)
tree7a082ee1141091afb3a20761d045ab0cf6cad5f4 /Lib/distutils/tests/test_sysconfig.py
parenta61b45980b4a6187e043abfb10c727b82e619ee2 (diff)
downloadcpython-46874ad367c2f3fdd47b2c8cb4b405bbcb2ed14a.zip
cpython-46874ad367c2f3fdd47b2c8cb4b405bbcb2ed14a.tar.gz
cpython-46874ad367c2f3fdd47b2c8cb4b405bbcb2ed14a.tar.bz2
Issue #15364: Fix sysconfig.get_config_var('srcdir') to be an absolute path.
Diffstat (limited to 'Lib/distutils/tests/test_sysconfig.py')
-rw-r--r--Lib/distutils/tests/test_sysconfig.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
index 545ef3b..546bb72 100644
--- a/Lib/distutils/tests/test_sysconfig.py
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -53,6 +53,34 @@ class SysconfigTestCase(support.EnvironGuard,
self.assertTrue(isinstance(cvars, dict))
self.assertTrue(cvars)
+ def test_srcdir(self):
+ # See Issues #15322, #15364.
+ srcdir = sysconfig.get_config_var('srcdir')
+
+ self.assertTrue(os.path.isabs(srcdir), srcdir)
+ self.assertTrue(os.path.isdir(srcdir), srcdir)
+
+ if sysconfig.python_build:
+ # The python executable has not been installed so srcdir
+ # should be a full source checkout.
+ Python_h = os.path.join(srcdir, 'Include', 'Python.h')
+ self.assertTrue(os.path.exists(Python_h), Python_h)
+ self.assertTrue(sysconfig._is_python_source_dir(srcdir))
+ elif os.name == 'posix':
+ self.assertEqual(sysconfig.get_makefile_filename(), srcdir)
+
+ def test_srcdir_independent_of_cwd(self):
+ # srcdir should be independent of the current working directory
+ # See Issues #15322, #15364.
+ srcdir = sysconfig.get_config_var('srcdir')
+ cwd = os.getcwd()
+ try:
+ os.chdir('..')
+ srcdir2 = sysconfig.get_config_var('srcdir')
+ finally:
+ os.chdir(cwd)
+ self.assertEqual(srcdir, srcdir2)
+
def test_customize_compiler(self):
# not testing if default compiler is not unix