aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_dist_info.py
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 /setuptools/tests/test_dist_info.py
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
Diffstat (limited to 'setuptools/tests/test_dist_info.py')
-rw-r--r--setuptools/tests/test_dist_info.py55
1 files changed, 55 insertions, 0 deletions
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)
+