diff options
author | pje <pje@6015fed2-1504-0410-9fe1-9d1591cc4771> | 2005-05-23 01:56:27 +0000 |
---|---|---|
committer | pje <pje@6015fed2-1504-0410-9fe1-9d1591cc4771> | 2005-05-23 01:56:27 +0000 |
commit | 9e4373a71b9f798fb0e09d66382f896cba0bcba4 (patch) | |
tree | 6a94346f805f6489f4f07c16a06bb1c8acf7f765 /setuptools/tests/test_resources.py | |
parent | 39907112d465d97c9a78f4da52e13841f620c223 (diff) | |
download | python-setuptools-9e4373a71b9f798fb0e09d66382f896cba0bcba4.tar.gz |
Add tests for AvailableDistributions().resolve(). This effectively
completes the core dependency resolution engine; all we need now is a way
to turn sys.path entries into "distribution sources" that can list
Distribution objects for inclusion in an instance of
AvailableDistributions, and the 'require("SomePkg>=2.7")' API will be
usable.
git-svn-id: http://svn.python.org/projects/sandbox/trunk/setuptools@41009 6015fed2-1504-0410-9fe1-9d1591cc4771
Diffstat (limited to 'setuptools/tests/test_resources.py')
-rw-r--r-- | setuptools/tests/test_resources.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index e2135ab..b6470e4 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -121,6 +121,47 @@ class DistroTests(TestCase): self.checkDepends(self.distDepends(v), v) + def testResolve(self): + ad = AvailableDistributions([]) + + # Resolving no requirements -> nothing to install + self.assertEqual( list(ad.resolve([],[])), [] ) + + # Request something not in the collection -> DistributionNotFound + self.assertRaises( + DistributionNotFound, ad.resolve, parse_requirements("Foo"), [] + ) + + Foo = Distribution.from_filename( + "/foo_dir/Foo-1.2.egg", + metadata=Metadata(('depends.txt', "[bar]\nBaz>=2.0")) + ) + ad.add(Foo) + + # Request thing(s) that are available -> list to install + self.assertEqual( + list(ad.resolve(parse_requirements("Foo"),[])), [Foo] + ) + + # Request an option that causes an unresolved dependency for "Baz" + self.assertRaises( + DistributionNotFound, ad.resolve,parse_requirements("Foo[bar]"),[] + ) + Baz = Distribution.from_filename( + "/foo_dir/Baz-2.1.egg", metadata=Metadata(('depends.txt', "Foo")) + ) + ad.add(Baz) + + # Install list now includes resolved dependency + self.assertEqual( + list(ad.resolve(parse_requirements("Foo[bar]"),[])), [Foo,Baz] + ) + # Requests for conflicting versions produce VersionConflict + self.assertRaises( + VersionConflict, + ad.resolve, parse_requirements("Foo==1.2\nFoo!=1.2"), [] + ) + def testDistroDependsOptions(self): d = self.distDepends(""" Twisted>=1.5 |