[Python-checkins] python/nondist/sandbox/setuptools/setuptools/tests doctest.py, NONE, 1.1 __init__.py, 1.7, 1.8 test_resources.py, 1.15, 1.16

pje@users.sourceforge.net pje at users.sourceforge.net
Mon Jul 18 03:39:48 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6719/setuptools/tests
Modified Files:
	__init__.py test_resources.py 
Added Files:
	doctest.py 
Log Message:
Massive API refactoring; see setuptools.txt changelog for details. Also,
add ``#egg=project-version`` link support, and docs on how to make your
package available for EasyInstall to find.
--- NEW FILE: doctest.py ---
# Module doctest.
# Released to the public domain 16-Jan-2001, by Tim Peters (tim at python.org).
# Major enhancements and refactoring by:
# Jim Fulton
# Edward Loper
# Provided as-is; use at your own risk; no warranty; no promises; enjoy!
try:
 basestring
except NameError:
 basestring = str,unicode
try:
 enumerate
except NameError:
 def enumerate(seq):
 return zip(range(len(seq)),seq)
[...2638 lines suppressed...]
 [0, 1, 2, ..., 999]
 """,
 "whitespace normalization": r"""
 If the whitespace normalization flag is used, then
 differences in whitespace are ignored.
 >>> print range(30) #doctest: +NORMALIZE_WHITESPACE
 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
 27, 28, 29]
 """,
 }
def _test():
 r = unittest.TextTestRunner()
 r.run(DocTestSuite())
if __name__ == "__main__":
 _test()
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests/__init__.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- __init__.py	6 Jul 2005 01:54:08 -0000	1.7
+++ __init__.py	18 Jul 2005 01:39:45 -0000	1.8
@@ -408,8 +408,15 @@
 
 
 
+def test_api():
+ import doctest
+ return doctest.DocFileSuite(
+ 'api_tests.txt', optionflags=doctest.ELLIPSIS, package='pkg_resources',
+ )
+
+
 testClasses = (DependsTests, DistroTests, FeatureTests, TestCommandTests)
-testNames = ["setuptools.tests.test_resources"]
+testNames = ["setuptools.tests.test_resources", "setuptools.tests.test_api"]
 
 def test_suite():
 return TestSuite(
@@ -442,10 +449,3 @@
 
 
 
-
-
-
-
-
-
-
Index: test_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests/test_resources.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- test_resources.py	17 Jul 2005 19:01:15 -0000	1.15
+++ test_resources.py	18 Jul 2005 01:39:45 -0000	1.16
@@ -54,23 +54,23 @@
 [dist.version for dist in ad['FooPkg']], ['1.9','1.4','1.2']
 )
 
- path = []
+ ws = WorkingSet([])
+ foo12 = Distribution.from_filename("FooPkg-1.2-py2.4.egg")
+ foo14 = Distribution.from_filename("FooPkg-1.4-py2.4-win32.egg")
 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')
-
+ self.assertEqual(ad.best_match(req,ws).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')
+ ws.add(foo14); self.assertEqual(ad.best_match(req,ws).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)
+ ws = WorkingSet([]); ws.add(foo12); ws.add(foo14)
+ self.assertRaises(VersionConflict, ad.best_match, req, ws)
 
 # 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')
+ ws = WorkingSet([]); ws.add(foo14); ws.add(foo12); ws.add(foo14);
+ self.assertEqual(ad.best_match(req,ws).version, '1.4')
 
 def checkFooPkg(self,d):
 self.assertEqual(d.project_name, "FooPkg")
@@ -86,8 +86,6 @@
 project_name="FooPkg",version="1.3-1",py_version="2.4",platform="win32"
 )
 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])
@@ -121,15 +119,17 @@
 self.checkDepends(self.distDepends(v), v)
 
 
+
+
 def testResolve(self):
- ad = AvailableDistributions([])
+ ad = AvailableDistributions([]); ws = WorkingSet([])
 
 # Resolving no requirements -> nothing to install
- self.assertEqual( list(ad.resolve([],[])), [] )
+ self.assertEqual( list(ws.resolve([],ad)), [] )
 
 # Request something not in the collection -> DistributionNotFound
 self.assertRaises(
- DistributionNotFound, ad.resolve, parse_requirements("Foo"), []
+ DistributionNotFound, ws.resolve, parse_requirements("Foo"), ad
 )
 
 Foo = Distribution.from_filename(
@@ -138,28 +138,28 @@
 )
 ad.add(Foo)
 
- # Request thing(s) that are available -> list to install
+ # Request thing(s) that are available -> list to activate
 self.assertEqual(
- list(ad.resolve(parse_requirements("Foo"),[])), [Foo]
+ list(ws.resolve(parse_requirements("Foo"), ad)), [Foo]
 )
 
- # Request an option that causes an unresolved dependency for "Baz"
+ # Request an extra that causes an unresolved dependency for "Baz"
 self.assertRaises(
- DistributionNotFound, ad.resolve,parse_requirements("Foo[bar]"),[]
+ DistributionNotFound, ws.resolve,parse_requirements("Foo[bar]"), ad
 ) 
 Baz = Distribution.from_filename(
 "/foo_dir/Baz-2.1.egg", metadata=Metadata(('depends.txt', "Foo"))
 )
 ad.add(Baz)
 
- # Install list now includes resolved dependency
+ # Activation list now includes resolved dependency
 self.assertEqual(
- list(ad.resolve(parse_requirements("Foo[bar]"),[])), [Foo,Baz]
+ list(ws.resolve(parse_requirements("Foo[bar]"), ad)), [Foo,Baz]
 )
 # Requests for conflicting versions produce VersionConflict
 self.assertRaises(
 VersionConflict,
- ad.resolve, parse_requirements("Foo==1.2\nFoo!=1.2"), []
+ ws.resolve, parse_requirements("Foo==1.2\nFoo!=1.2"), ad
 )
 
 def testDistroDependsOptions(self):
@@ -208,7 +208,7 @@
 def testBasics(self):
 r = Requirement.parse("Twisted>=1.2")
 self.assertEqual(str(r),"Twisted>=1.2")
- self.assertEqual(repr(r),"Requirement('Twisted', [('>=', '1.2')], ())")
+ self.assertEqual(repr(r),"Requirement.parse('Twisted>=1.2')")
 self.assertEqual(r, Requirement("Twisted", [('>=','1.2')]))
 self.assertEqual(r, Requirement("twisTed", [('>=','1.2')]))
 self.assertNotEqual(r, Requirement("Twisted", [('>=','2.0')]))
@@ -285,13 +285,6 @@
 
 
 
-
-
-
-
-
-
-
 class ParseTests(TestCase):
 
 def testEmptyParse(self):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /