[Python-checkins] python/nondist/sandbox/setuptools/setuptools/tests test_resources.py, 1.9, 1.10

pje@users.sourceforge.net pje at users.sourceforge.net
Mon May 23 03:56:29 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17806/setuptools/tests

Modified Files:
	test_resources.py 
Log Message:
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.


Index: test_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests/test_resources.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- test_resources.py	22 May 2005 20:28:47 -0000	1.9
+++ test_resources.py	23 May 2005 01:56:27 -0000	1.10
@@ -121,6 +121,47 @@
             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



More information about the Python-checkins mailing list