Issue137

Title test_get_script_header_jython_workaround expects output on stdout, but it is on stderr instead
Priority bug Status unread
Superseder Nosy List zooko
Assigned To Keywords

Created on 2011-11-25.18:19:33 by zooko, last changed 2011-11-25.18:19:33 by zooko.

Messages
msg653 (view) Author: zooko Date: 2011-11-25.18:19:33
This unit test fails on CPython 2.7.1 and pypy 1.7:

FAIL: test_get_script_header_jython_workaround (setuptools.tests.test_resources.ScriptHeaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/zooko/playground/setuptools/setuptools/tests/test_resources.py", line 524, in test_get_script_header_jython_workaround
    self.assert_('Unable to adapt shebang line' in sys.stdout.getvalue())
AssertionError: False is not true


The following patch makes it pass on those two pythons:

Index: setuptools/tests/test_resources.py
===================================================================
--- setuptools/tests/test_resources.py  (revision 88925)
+++ setuptools/tests/test_resources.py  (working copy)
@@ -507,7 +507,7 @@
     def test_get_script_header_jython_workaround(self):
         platform = sys.platform
         sys.platform = 'java1.5.0_13'
-        stdout = sys.stdout
+        stderr = sys.stderr
         try:
             # A mock sys.executable that uses a shebang line (this file)
             exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py')
@@ -517,17 +517,17 @@
 
             # Ensure we generate what is basically a broken shebang line
             # when there's options, with a warning emitted
-            sys.stdout = StringIO.StringIO()
+            sys.stderr = StringIO.StringIO()
             self.assertEqual(get_script_header('#!/usr/bin/python -x',
                                                executable=exe),
                              '#!%s  -x\n' % exe)
-            self.assert_('Unable to adapt shebang line' in sys.stdout.getvalue())
-            sys.stdout = StringIO.StringIO()
+            self.assert_('Unable to adapt shebang line' in sys.stderr.getvalue())
+            sys.stderr = StringIO.StringIO()
             self.assertEqual(get_script_header('#!/usr/bin/python',
                                                executable=self.non_ascii_exe),
                              '#!%s -x\n' % self.non_ascii_exe)
-            self.assert_('Unable to adapt shebang line' in sys.stdout.getvalue())
+            self.assert_('Unable to adapt shebang line' in sys.stderr.getvalue())
         finally:
             sys.platform = platform
-            sys.stdout = stdout
+            sys.stderr = stderr
History
Date User Action Args
2011-11-25 18:19:33zookocreate