aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Holth <dholth@fastmail.fm>2012-07-07 23:24:20 -0400
committerDaniel Holth <dholth@fastmail.fm>2012-07-07 23:24:20 -0400
commitb73bf20cea512d0d95a29db4fd9ed837130c54fc (patch)
tree660060a3cf5f4aa780c2d3fc932d226b4de1c865
parent0d5901c018dbccaa9bffc8902796b40a546f7f3d (diff)
downloadexternal_python_setuptools-b73bf20cea512d0d95a29db4fd9ed837130c54fc.tar.gz
external_python_setuptools-b73bf20cea512d0d95a29db4fd9ed837130c54fc.tar.bz2
external_python_setuptools-b73bf20cea512d0d95a29db4fd9ed837130c54fc.zip
test .dist-info distributions
--HG-- branch : distribute extra : rebase_source : ea6870d73aa69f2deacc50beb2e257d3c21073e4
-rw-r--r--pkg_resources.py16
-rw-r--r--setuptools/tests/test_dist_info.py55
2 files changed, 56 insertions, 15 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 285aa1bb..27b9f834 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -2514,21 +2514,7 @@ class DistInfoDistribution(Distribution):
dm[extra] = list(set(reqs_for_extra(extra)) - common)
return dm
-
- def requires(self,extras=()):
- """List of Requirements needed for this distro if `extras` are used"""
- dm = self._dep_map
- deps = []
- deps.extend(dm.get(None,()))
- for ext in extras:
- try:
- deps.extend(dm[safe_extra(ext)])
- except KeyError:
- raise UnknownExtra(
- "%s has no such extra feature %r" % (self, ext)
- )
- return deps
-
+
_distributionImpl = {'.egg': Distribution,
'.egg-info': Distribution,
diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py
new file mode 100644
index 00000000..c40886d3
--- /dev/null
+++ b/setuptools/tests/test_dist_info.py
@@ -0,0 +1,55 @@
+"""Test .dist-info style distributions.
+"""
+import os, shutil, tempfile, unittest
+import pkg_resources
+from pkg_resources import Requirement
+
+class TestDistInfo(unittest.TestCase):
+
+ def test_distinfo(self):
+ dists = {}
+ for d in pkg_resources.find_distributions(self.tmpdir):
+ dists[d.project_name] = d
+
+ unversioned = dists['UnversionedDistribution']
+ versioned = dists['VersionedDistribution']
+
+ assert versioned.version == '2.718' # from filename
+ assert unversioned.version == '0.3' # from METADATA
+
+ requires = [Requirement.parse('splort==4'),
+ Requirement.parse('quux>=1.1')]
+
+ for d in (unversioned, versioned):
+ self.assertEquals(d.requires(), requires[:1])
+ self.assertEquals(d.requires(extras=('baz',)), requires)
+ self.assertEquals(d.extras, ['baz'])
+
+ def setUp(self):
+ self.tmpdir = tempfile.mkdtemp()
+ 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'
+""")
+
+ 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'
+""")
+
+ def tearDown(self):
+ shutil.rmtree(self.tmpdir)
+