[Python-checkins] python/nondist/sandbox/setuptools/setuptools/tests test_resources.py, 1.2, 1.3

pje at users.sourceforge.net pje at users.sourceforge.net
Sun Apr 3 02:47:01 CEST 2005


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

Modified Files:
	test_resources.py 
Log Message:
Add a "Distribution" object that wraps a sys.path entry with metadata, and
can extract its name/version/pythonversion/platform if built from a .egg
filename.  Later, distributions will be able to add themselves to sys.path
and request that their dependencies be added as well.  Also, added some
real-life version test cases supplied by jemfinch.


Index: test_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests/test_resources.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test_resources.py	2 Apr 2005 23:31:13 -0000	1.2
+++ test_resources.py	3 Apr 2005 00:46:58 -0000	1.3
@@ -1,13 +1,46 @@
 from unittest import TestCase, makeSuite
 from pkg_resources import *
-import pkg_resources
+import pkg_resources, sys
 
 class DistroTests(TestCase):
+
     def testEmptyiter(self):
         # empty path should produce no distributions
         self.assertEqual(list(iter_distributions(path=[])), [])
 
+    def checkFooPkg(self,d):
+        self.assertEqual(d.name, "FooPkg")
+        self.assertEqual(d.key, "foopkg")
+        self.assertEqual(d.version, "1.3-1")
+        self.assertEqual(d.py_version, "2.4")
+        self.assertEqual(d.parsed_version, parse_version("1.3-1"))
+        
+    def testDistroBasics(self):
+        d = Distribution(
+            "/some/path",
+            name="FooPkg",version="1.3-1",py_version="2.4"
+        )
+        self.checkFooPkg(d)
+        self.failUnless(d.installed_on(["/some/path"]))
+        self.failIf(d.installed_on([]))
+
+        d = Distribution("/some/path")
+        self.assertEqual(d.py_version, sys.version[:3])
+
+    def testDistroParse(self):
+        d = Distribution.from_filename("FooPkg-1.3_1-py2.4-win32.egg")
+        self.checkFooPkg(d)
+        
+
+
+
+
+
+
+
+
 class ParseTests(TestCase):
+
     def testEmptyParse(self):
         self.assertEqual(list(parse_requirements('')), [])
 
@@ -39,14 +72,22 @@
 
 
 
+
+
+
+
+
+
+
+
     def testVersionOrdering(self):
         def c(s1,s2):
             p1, p2 = parse_version(s1),parse_version(s2)
             self.failUnless(p1<p2, (s1,s2,p1,p2))
 
         c('2.1','2.1.1')
-        c('2a1','2b0')        
-        c('2a1','2.1')        
+        c('2a1','2b0')
+        c('2a1','2.1')
         c('2.3a1', '2.3')
         c('2.1-1', '2.1-2')
         c('2.1-1', '2.1.1')
@@ -61,12 +102,30 @@
         c('0.0.4', '0.4.0')
         c('0pl1', '0.4pl1')
 
+        torture ="""
+        0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1
+        0.79.9999+0.80.0pre2-3 0.79.9999+0.80.0pre2-2
+        0.77.2-1 0.77.1-1 0.77.0-1
+        """.split()
+        
+        for p,v1 in enumerate(torture):
+            for v2 in torture[p+1:]:
+                c(v2,v1)
+
+
+
+
+
+
+
+
+
 
     def testVersionEquality(self):
         def c(s1,s2):
             p1, p2 = parse_version(s1),parse_version(s2)
             self.assertEqual(p1,p2, (s1,s2,p1,p2))
-        
+
         c('0.4', '0.4.0')
         c('0.4.0.0', '0.4.0')
         c('0.4.0-0', '0.4-0')
@@ -75,7 +134,21 @@
         c('0.0.0preview1', '0c1')
         c('0.0c1', '0rc1')
 
-        
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 



More information about the Python-checkins mailing list