Commits

Hanno Schlichting committed 28b7885

Move script header tests to distribute.installer as the tested functions are defined there

Comments (0)

Files changed (2)

distribute.installer/distribute/installer/tests/test_scripts.py

+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# NOTE: the shebang and encoding lines are for ScriptHeaderTests; do not remove
+from unittest import TestCase
+from distribute.installer.command.easy_install import get_script_header, is_sh
+import os, sys, StringIO
+
+
+class ScriptHeaderTests(TestCase):
+    non_ascii_exe = '/Users/José/bin/python'
+
+    def test_get_script_header(self):
+        if not sys.platform.startswith('java') or not is_sh(sys.executable):
+            # This test is for non-Jython platforms
+            self.assertEqual(get_script_header('#!/usr/local/bin/python'),
+                             '#!%s\n' % os.path.normpath(sys.executable))
+            self.assertEqual(get_script_header('#!/usr/bin/python -x'),
+                             '#!%s  -x\n' % os.path.normpath(sys.executable))
+            self.assertEqual(get_script_header('#!/usr/bin/python',
+                                               executable=self.non_ascii_exe),
+                             '#!%s -x\n' % self.non_ascii_exe)
+
+    def test_get_script_header_jython_workaround(self):
+        platform = sys.platform
+        sys.platform = 'java1.5.0_13'
+        stdout = sys.stdout
+        try:
+            # A mock sys.executable that uses a shebang line (this file)
+            exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py')
+            self.assertEqual(
+                get_script_header('#!/usr/local/bin/python', executable=exe),
+                '#!/usr/bin/env %s\n' % exe)
+
+            # Ensure we generate what is basically a broken shebang line
+            # when there's options, with a warning emitted
+            sys.stdout = 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.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())
+        finally:
+            sys.platform = platform
+            sys.stdout = stdout
+

distribute.resources/distribute/resources/tests/test_resources.py

-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-# NOTE: the shebang and encoding lines are for ScriptHeaderTests; do not remove
-from unittest import TestCase, makeSuite
-from distribute.resources import *
-from distribute import resources
-from distribute.installer.command.easy_install import get_script_header, is_sh
+from unittest import TestCase
+from distribute.resources import DistributionNotFound
+from distribute.resources import Environment
+from distribute.resources import UnknownExtra
+from distribute.resources import VersionConflict
+from distribute.resources import WorkingSet
 from distribute.resources.providers import EmptyProvider
 from distribute.resources.entrypoint import EntryPoint
 from distribute.resources.requirement import Requirement, parse_requirements
 from distribute.resources.dist import Distribution
 from distribute.resources.util import (yield_lines, split_sections,
                                        safe_version, safe_name)
-import os, sys, StringIO
+import sys
 
 try:
     frozenset
         for p,v1 in enumerate(torture):
             for v2 in torture[p+1:]:
                 c(v2,v1)
-
-
-
-
-
-
-
-
-class ScriptHeaderTests(TestCase):
-    non_ascii_exe = '/Users/José/bin/python'
-
-    def test_get_script_header(self):
-        if not sys.platform.startswith('java') or not is_sh(sys.executable):
-            # This test is for non-Jython platforms
-            self.assertEqual(get_script_header('#!/usr/local/bin/python'),
-                             '#!%s\n' % os.path.normpath(sys.executable))
-            self.assertEqual(get_script_header('#!/usr/bin/python -x'),
-                             '#!%s  -x\n' % os.path.normpath(sys.executable))
-            self.assertEqual(get_script_header('#!/usr/bin/python',
-                                               executable=self.non_ascii_exe),
-                             '#!%s -x\n' % self.non_ascii_exe)
-
-    def test_get_script_header_jython_workaround(self):
-        platform = sys.platform
-        sys.platform = 'java1.5.0_13'
-        stdout = sys.stdout
-        try:
-            # A mock sys.executable that uses a shebang line (this file)
-            exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py')
-            self.assertEqual(
-                get_script_header('#!/usr/local/bin/python', executable=exe),
-                '#!/usr/bin/env %s\n' % exe)
-
-            # Ensure we generate what is basically a broken shebang line
-            # when there's options, with a warning emitted
-            sys.stdout = 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.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())
-        finally:
-            sys.platform = platform
-            sys.stdout = stdout
-