summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-05-22 18:17:00 +0000
committerPJ Eby <distutils-sig@python.org>2005-05-22 18:17:00 +0000
commit05d3b06a6f5119ae4cb327989c36e21d927449c3 (patch)
tree50cae6bcc6abaf80faffd2967d71240935dd2b1b /setuptools
parent9511ddad57df2a1c5c0bfed2967d773cdd536607 (diff)
downloadpython-setuptools-git-05d3b06a6f5119ae4cb327989c36e21d927449c3.tar.gz
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. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041006
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/tests/test_resources.py61
1 files changed, 51 insertions, 10 deletions
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index 52197fe9..c90b907d 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -39,6 +39,47 @@ class DistroTests(TestCase):
[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 DistroTests(TestCase):
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 @@ class ParseTests(TestCase):
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,"#")