Issue #7880: Fix sysconfig when the python executable is a symbolic link.

This commit is contained in:
Florent Xicluna 2010-03-10 23:58:42 +00:00
parent 3ec32005e8
commit 85677617d5
3 changed files with 27 additions and 7 deletions

View file

@ -8,9 +8,10 @@ import unittest
import sys
import os
import shutil
import subprocess
from copy import copy, deepcopy
from test.test_support import run_unittest, TESTFN
from test.test_support import run_unittest, TESTFN, unlink, get_attribute
import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars,
@ -238,6 +239,23 @@ class TestSysConfig(unittest.TestCase):
'posix_prefix', 'posix_user')
self.assertEquals(get_scheme_names(), wanted)
def test_symlink(self):
# Issue 7880
symlink = get_attribute(os, "symlink")
def get(python):
cmd = [python, '-c',
'import sysconfig; print sysconfig.get_platform()']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
return p.communicate()
real = os.path.realpath(sys.executable)
link = os.path.abspath(TESTFN)
symlink(real, link)
try:
self.assertEqual(get(real), get(link))
finally:
unlink(link)
def test_main():
run_unittest(TestSysConfig)