aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-03 03:16:28 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-03 03:16:28 -0500
commita1ef38f99bc7df9464c4a2bcb3c374a9c81da6d1 (patch)
tree05128268149af46bce890d892857ddfcace7a447
parentf3875aa79c616d605b86a7c60c35c627401a4953 (diff)
downloadexternal_python_setuptools-a1ef38f99bc7df9464c4a2bcb3c374a9c81da6d1.tar.gz
external_python_setuptools-a1ef38f99bc7df9464c4a2bcb3c374a9c81da6d1.tar.bz2
external_python_setuptools-a1ef38f99bc7df9464c4a2bcb3c374a9c81da6d1.zip
Use contexts.quiet for stdout/stderr trapping
-rw-r--r--setuptools/tests/test_easy_install.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index cd023480..f45e5c63 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -451,8 +451,7 @@ class TestScriptHeader:
mock.Mock(getProperty=mock.Mock(return_value="")))))
@mock.patch('sys.platform', 'java1.5.0_13')
def test_get_script_header_jython_workaround(self):
- stdout, stderr = sys.stdout, sys.stderr
- try:
+ with contexts.quiet() as (stdout, stderr):
# A mock sys.executable that uses a shebang line (this file)
exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py')
assert (
@@ -463,15 +462,13 @@ class TestScriptHeader:
# Ensure we generate what is basically a broken shebang line
# when there's options, with a warning emitted
- sys.stdout = sys.stderr = StringIO()
candidate = get_script_header('#!/usr/bin/python -x',
executable=exe)
assert candidate == '#!%s -x\n' % exe
- assert 'Unable to adapt shebang line' in sys.stdout.getvalue()
- sys.stdout = sys.stderr = StringIO()
+ assert 'Unable to adapt shebang line' in stderr.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 sys.stdout.getvalue()
- finally:
- sys.stdout, sys.stderr = stdout, stderr
+ assert 'Unable to adapt shebang line' in stderr.getvalue()