[Python-checkins] python/nondist/sandbox/setuptools/setuptools/tests test_resources.py, 1.6, 1.7

pje@users.sourceforge.net pje at users.sourceforge.net
Sun May 22 20:17:02 CEST 2005


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

Modified Files:
	test_resources.py 
Log Message:
Refine dependency resolution algorithm so it won't take exponential time,
or bomb on cyclic dependencies.  (But it's still an untested sketch.)
Added list of things that need to be implemented before dependency
resolution can actually work.  Added tests for lower-level parts of the 
dependency resolution system, and a hook to support subclasses doing
automatic download of needed dependencies.


Index: test_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests/test_resources.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_resources.py	21 May 2005 21:42:57 -0000	1.6
+++ test_resources.py	22 May 2005 18:17:00 -0000	1.7
@@ -39,6 +39,47 @@
             [dist.version for dist in ad['FooPkg']], ['1.9','1.4','1.2']
         )
 
+        path = []
+        req, = parse_requirements("FooPkg>=1.3")
+
+        # Nominal case: no distros on path, should yield all applicable
+        self.assertEqual(ad.best_match(req,path).version, '1.9')
+
+        # If a matching distro is already installed, should return only that
+        path.append("FooPkg-1.4-py2.4-win32.egg")
+        self.assertEqual(ad.best_match(req,path).version, '1.4')
+
+        # If the first matching distro is unsuitable, it's a version conflict
+        path.insert(0,"FooPkg-1.2-py2.4.egg")
+        self.assertRaises(VersionConflict, ad.best_match, req, path)        
+
+        # If more than one match on the path, the first one takes precedence
+        path.insert(0,"FooPkg-1.4-py2.4-win32.egg")
+        self.assertEqual(ad.best_match(req,path).version, '1.4')
+        
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     def checkFooPkg(self,d):
         self.assertEqual(d.name, "FooPkg")
         self.assertEqual(d.key, "foopkg")
@@ -83,7 +124,7 @@
 class RequirementsTests(TestCase):
 
     def testBasics(self):
-        r = Requirement("Twisted", [('>=','1.2')])
+        r = Requirement.parse("Twisted>=1.2")
         self.assertEqual(str(r),"Twisted>=1.2")
         self.assertEqual(repr(r),"Requirement('Twisted', [('>=', '1.2')])")
         self.assertEqual(r, Requirement("Twisted", [('>=','1.2')]))
@@ -142,15 +183,15 @@
             list(parse_requirements('Twisted >=1.2, \ # more\n<2.0')),
             [Requirement('Twisted',[('>=','1.2'),('<','2.0')])]
         )
-        self.assertRaises(ValueError,lambda:list(parse_requirements(">=2.3")))
-        self.assertRaises(ValueError,lambda:list(parse_requirements("x\\")))
-        self.assertRaises(ValueError,lambda:list(parse_requirements("x==2 q")))
-
-
-
-
-
-
+        self.assertEqual(
+            Requirement.parse("FooBar==1.99a3"),
+            Requirement("FooBar", [('==','1.99a3')])
+        )
+        self.assertRaises(ValueError,Requirement.parse,">=2.3")
+        self.assertRaises(ValueError,Requirement.parse,"x\\")
+        self.assertRaises(ValueError,Requirement.parse,"x==2 q")
+        self.assertRaises(ValueError,Requirement.parse,"X==1\nY==2")
+        self.assertRaises(ValueError,Requirement.parse,"#")
 
 
 



More information about the Python-checkins mailing list