summaryrefslogtreecommitdiff
path: root/setuptools/tests
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-04-02 02:43:21 +0000
committerPJ Eby <distutils-sig@python.org>2005-04-02 02:43:21 +0000
commit6d3753cc8d96814a99cedd8a24a57977e5ef7766 (patch)
tree025f6cb23e724bdefed8bd372490bfe65fb742f8 /setuptools/tests
parent0ad2e2ea4e3814a8ce02149878932c036f02477b (diff)
downloadpython-setuptools-git-6d3753cc8d96814a99cedd8a24a57977e5ef7766.tar.gz
Rough draft of version requirement parser. Make bdist_egg look for a
distname.egg-info directory instead of EGG-INFO.in; this will be used later to support development of egg-distributed packages that an application under development expects to 'require()'. (Thanks to Fred Drake for pointing out this use case, and Bob Ippolito for helping me figure out how to support it, although the runtime support doesn't actually exist yet.) --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4040999
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/__init__.py12
-rw-r--r--setuptools/tests/test_resources.py33
2 files changed, 39 insertions, 6 deletions
diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py
index 913c65bf..7db37888 100644
--- a/setuptools/tests/__init__.py
+++ b/setuptools/tests/__init__.py
@@ -1,6 +1,6 @@
"""Tests for the 'setuptools' package"""
-from unittest import TestSuite, TestCase, makeSuite
+from unittest import TestSuite, TestCase, makeSuite, defaultTestLoader
import distutils.core, distutils.cmd
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.errors import DistutilsSetupError
@@ -409,13 +409,13 @@ class TestCommandTests(TestCase):
testClasses = (DependsTests, DistroTests, FeatureTests, TestCommandTests)
+testNames = ["setuptools.tests.test_resources"]
def test_suite():
- return TestSuite([makeSuite(t,'test') for t in testClasses])
-
-
-
-
+ return TestSuite(
+ [makeSuite(t,'test') for t in testClasses]+
+ [defaultTestLoader.loadTestsFromName(n) for n in testNames]
+ )
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
new file mode 100644
index 00000000..f918d21b
--- /dev/null
+++ b/setuptools/tests/test_resources.py
@@ -0,0 +1,33 @@
+from unittest import TestCase, makeSuite
+from pkg_resources import *
+import pkg_resources
+
+class DistroTests(TestCase):
+ def testEmptyiter(self):
+ # empty path should produce no distributions
+ self.assertEqual(list(iter_distributions(path=[])), [])
+
+class ParseTests(TestCase):
+ def testEmptyParse(self):
+ self.assertEqual(list(parse_requirements('')), [])
+
+ def testYielding(self):
+ for inp,out in [
+ ([], []), ('x',['x']), ([[]],[]), (' x\n y', ['x','y']),
+ (['x\n\n','y'], ['x','y']),
+ ]:
+ self.assertEqual(list(pkg_resources.yield_lines(inp)),out)
+
+ def testSimple(self):
+ self.assertEqual(
+ list(parse_requirements('Twis-Ted>=1.2')),
+ [('Twis_Ted',[('>=','1.2')])]
+ )
+ self.assertEqual(
+ list(parse_requirements('Twisted >=1.2, \ # more\n<2.0')),
+ [('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")))
+