summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-04-03 00:46:58 +0000
committerPJ Eby <distutils-sig@python.org>2005-04-03 00:46:58 +0000
commit7311c34af4aa1ab305021fa9df99eaf63bb15ebe (patch)
treea0d8d65cd261e613ae17fffd80c437bb29836581 /setuptools
parent1a7cff662b734fed26360983b961ce70b889767e (diff)
downloadpython-setuptools-git-7311c34af4aa1ab305021fa9df99eaf63bb15ebe.tar.gz
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. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041001
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/tests/test_resources.py83
1 files changed, 78 insertions, 5 deletions
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index 8797cda9..7cde4013 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -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 @@ class ParseTests(TestCase):
+
+
+
+
+
+
+
+
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 @@ class ParseTests(TestCase):
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 @@ class ParseTests(TestCase):
c('0.0.0preview1', '0c1')
c('0.0c1', '0rc1')
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+