2
Test suite for OS X interpreter environment variables.
5
from test.support import EnvironmentVarGuard, run_unittest
10
class OSXEnvironmentVariableTestCase(unittest.TestCase):
11
def _check_sys(self, ev, cond, sv, val = '/some/path/to/python'):
12
with EnvironmentVarGuard() as evg:
13
subpc = [str(sys.executable), '-c',
14
'import sys; sys.exit(2 if "%s" %s %s else 3)' % (val, cond, sv)]
15
# ensure environment variable does not exist
17
# test that test on sys.xxx normally fails
18
rc = subprocess.call(subpc)
19
self.assertEqual(rc, 3, "expected %s not %s %s" % (ev, cond, sv))
20
# set environ variable
22
# test that sys.xxx has been influenced by the environ value
23
rc = subprocess.call(subpc)
24
self.assertEqual(rc, 2, "expected %s %s %s" % (ev, cond, sv))
26
def test_pythonexecutable_sets_sys_executable(self):
27
self._check_sys('PYTHONEXECUTABLE', '==', 'sys.executable')
30
from distutils import sysconfig
32
if sys.platform == 'darwin' and sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'):
33
run_unittest(OSXEnvironmentVariableTestCase)
35
if __name__ == "__main__":