Jason R. Coombs avatar Jason R. Coombs committed 31fd0e5

Use DALS to avoid breaking indentation in test setup. Removed flag indicating presence of module.

Comments (0)

Files changed (1)

setuptools/tests/test_dist_info.py

 import shutil
 import tempfile
 import unittest
+import textwrap
+
+try:
+    import markerlib
+except:
+    pass
 
 import pkg_resources
-from pkg_resources import Requirement
-try:
-    import markerlib
-    has_markerlib = True
-except:
-    has_markerlib = False
+
+def DALS(s):
+    "dedent and left-strip"
+    return textwrap.dedent(s).lstrip()
 
 class TestDistInfo(unittest.TestCase):
 
         assert versioned.version == '2.718' # from filename
         assert unversioned.version == '0.3' # from METADATA
 
-    @unittest.skipIf(not has_markerlib,
+    @unittest.skipIf('markerlib' not in globals(),
                      "install markerlib to test conditional dependencies")
     def test_conditional_dependencies(self):
-        requires = [Requirement.parse('splort==4'),
-                    Requirement.parse('quux>=1.1')]
+        requires = [pkg_resources.Requirement.parse('splort==4'),
+                    pkg_resources.Requirement.parse('quux>=1.1')]
 
         for d in pkg_resources.find_distributions(self.tmpdir):
             self.assertEquals(d.requires(), requires[:1])
         versioned = os.path.join(self.tmpdir,
                                  'VersionedDistribution-2.718.dist-info')
         os.mkdir(versioned)
-        open(os.path.join(versioned, 'METADATA'), 'w+').write(
-"""Metadata-Version: 1.2
-Name: VersionedDistribution
-Requires-Dist: splort (4)
-Provides-Extra: baz
-Requires-Dist: quux (>=1.1); extra == 'baz'
-""")
+        open(os.path.join(versioned, 'METADATA'), 'w+').write(DALS(
+            """Metadata-Version: 1.2
+            Name: VersionedDistribution
+            Requires-Dist: splort (4)
+            Provides-Extra: baz
+            Requires-Dist: quux (>=1.1); extra == 'baz'
+            """))
 
         unversioned = os.path.join(self.tmpdir,
                                    'UnversionedDistribution.dist-info')
         os.mkdir(unversioned)
-        open(os.path.join(unversioned, 'METADATA'), 'w+').write(
-"""Metadata-Version: 1.2
-Name: UnversionedDistribution
-Version: 0.3
-Requires-Dist: splort (==4)
-Provides-Extra: baz
-Requires-Dist: quux (>=1.1); extra == 'baz'
-""")
+        open(os.path.join(unversioned, 'METADATA'), 'w+').write(DALS(
+            """Metadata-Version: 1.2
+            Name: UnversionedDistribution
+            Version: 0.3
+            Requires-Dist: splort (==4)
+            Provides-Extra: baz
+            Requires-Dist: quux (>=1.1); extra == 'baz'
+            """))
 
     def tearDown(self):
         shutil.rmtree(self.tmpdir)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.