diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-03 03:43:32 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-03 03:43:32 -0500 |
commit | 928324bd76f35e9c8c526df828577b5640a95ed0 (patch) | |
tree | 04d4e1e91c24e0a7c57bf479cbdbdf07b713a043 /setuptools/tests/test_easy_install.py | |
parent | 6a8e7310535e4f76e972de00154ac83a69721896 (diff) | |
parent | a849ee957f3ba12945278f88e473eb3612faf4b9 (diff) | |
download | external_python_setuptools-928324bd76f35e9c8c526df828577b5640a95ed0.tar.gz external_python_setuptools-928324bd76f35e9c8c526df828577b5640a95ed0.tar.bz2 external_python_setuptools-928324bd76f35e9c8c526df828577b5640a95ed0.zip |
Merge with master
--HG--
branch : feature/issue-229
Diffstat (limited to 'setuptools/tests/test_easy_install.py')
-rw-r--r-- | setuptools/tests/test_easy_install.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index f09e7e00..5d5ec16d 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -1,6 +1,4 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -# NOTE: the shebang and encoding lines are for TestScriptHeader do not remove +#! -*- coding: utf-8 -*- """Easy install Tests """ @@ -446,22 +444,34 @@ class TestScriptHeader: @mock.patch.dict(sys.modules, java=mock.Mock(lang=mock.Mock(System= mock.Mock(getProperty=mock.Mock(return_value=""))))) @mock.patch('sys.platform', 'java1.5.0_13') - def test_get_script_header_jython_workaround(self): - # A mock sys.executable that uses a shebang line (this file) - exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py') + def test_get_script_header_jython_workaround(self, tmpdir): + # Create a mock sys.executable that uses a shebang line + header = DALS(""" + #!/usr/bin/python + # -*- coding: utf-8 -*- + """) + exe = tmpdir / 'exe.py' + with exe.open('w') as f: + f.write(header) + exe = str(exe) + header = get_script_header('#!/usr/local/bin/python', executable=exe) assert header == '#!/usr/bin/env %s\n' % exe + expect_out = 'stdout' if sys.version_info < (2,7) else 'stderr' + with contexts.quiet() as (stdout, stderr): # When options are included, generate a broken shebang line # with a warning emitted candidate = get_script_header('#!/usr/bin/python -x', executable=exe) assert candidate == '#!%s -x\n' % exe - assert 'Unable to adapt shebang line' in stderr.getvalue() + output = locals()[expect_out] + assert 'Unable to adapt shebang line' in output.getvalue() with contexts.quiet() as (stdout, stderr): candidate = get_script_header('#!/usr/bin/python', executable=self.non_ascii_exe) assert candidate == '#!%s -x\n' % self.non_ascii_exe - assert 'Unable to adapt shebang line' in stderr.getvalue() + output = locals()[expect_out] + assert 'Unable to adapt shebang line' in output.getvalue() |