Commit c62d8121 authored by Daniel Holth's avatar Daniel Holth

improve .dist-info test

--HG--
branch : distribute
extra : rebase_source : 23b6b4023d413bf1b27b114687da8736a4b38d8b
parent b73bf20c
......@@ -3,6 +3,11 @@
import os, shutil, tempfile, unittest
import pkg_resources
from pkg_resources import Requirement
try:
import markerlib
has_markerlib = True
except:
has_markerlib = False
class TestDistInfo(unittest.TestCase):
......@@ -11,19 +16,24 @@ class TestDistInfo(unittest.TestCase):
for d in pkg_resources.find_distributions(self.tmpdir):
dists[d.project_name] = d
assert len(dists) == 2, dists
unversioned = dists['UnversionedDistribution']
versioned = dists['VersionedDistribution']
assert versioned.version == '2.718' # from filename
assert unversioned.version == '0.3' # from METADATA
@unittest.skipIf(not has_markerlib,
"install markerlib to test conditional dependencies")
def test_conditional_dependencies(self):
requires = [Requirement.parse('splort==4'),
Requirement.parse('quux>=1.1')]
for d in (unversioned, versioned):
for d in pkg_resources.find_distributions(self.tmpdir):
self.assertEquals(d.requires(), requires[:1])
self.assertEquals(d.requires(extras=('baz',)), requires)
self.assertEquals(d.extras, ['baz'])
self.assertEquals(d.extras, ['baz'])
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment