[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/tests - testContainerTraversable.py:1.3 testContainerTraverser.py:1.4
Barry Warsaw
barry@wooz.org
Fri, 20 Dec 2002 15:22:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/tests
In directory cvs.zope.org:/tmp/cvs-serv18378/lib/python/Zope/App/OFS/Container/tests
Modified Files:
testContainerTraversable.py testContainerTraverser.py
Log Message:
test module cleanups:
- no docstrings in test methods (convert to comments)
- whitespace normalization
- other minor cleanups
=== Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraversable.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraversable.py:1.2 Mon Jun 10 19:27:57 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraversable.py Fri Dec 20 15:22:10 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -20,7 +20,7 @@
from Zope.App.OFS.Container.ContainerTraversable import ContainerTraversable
from Zope.Exceptions import NotFoundError
from Zope.App.OFS.Container.IContainer import IContainer
-from Zope.Testing.CleanUp import CleanUp
+from Zope.Testing.CleanUp import CleanUp
class Container:
@@ -30,42 +30,42 @@
def __init__(self, attrs={}, objs={}):
for attr,value in attrs.iteritems():
setattr(self, attr, value)
-
+
self.__objs = {}
for name,value in objs.iteritems():
self.__objs[name] = value
-
-
+
+
def __getitem__(self, name):
return self.__objs[name]
-
+
def get(self, name, default=None):
return self.__objs.get(name, default)
def __contains__(self, name):
return self.__objs.has_key(name)
-class Test(CleanUp, unittest.TestCase):
+class Test(CleanUp, unittest.TestCase):
def testAttr(self):
- """ test container path traversal """
-
+ # test container path traversal
foo = Container()
bar = Container()
baz = Container()
c = Container( {'foo':foo}, {'bar':bar, 'foo':baz} )
-
+
T = ContainerTraversable(c)
self.failUnless(T.traverse('foo', (), 'foo', []) is baz)
self.failUnless(T.traverse('bar', (), 'bar', []) is bar)
-
+
self.assertRaises(NotFoundError , T.traverse,
'morebar', (), 'morebar', [])
-
+
def test_suite():
- loader=unittest.TestLoader()
+ loader = unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
-if __name__=='__main__':
+
+if __name__ == '__main__':
unittest.TextTestRunner().run(test_suite())
=== Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraverser.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraverser.py:1.3 Fri Oct 4 14:37:16 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraverser.py Fri Dec 20 15:22:10 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -25,76 +25,66 @@
from Zope.App.OFS.Container.IContainer import IContainer
from Zope.App.tests.PlacelessSetup import PlacelessSetup
-class I(Interface): pass
+class I(Interface):
+ pass
class Container:
-
__implements__ = IContainer
def __init__(self, **kw):
-
for k in kw:
setattr(self, k , kw[k])
-
def get(self, name, default=None):
-
return getattr(self, name, default)
-
-class Request(Request):
+class Request(Request):
def getEffectiveURL(self):
return ''
-class View:
+class View:
def __init__(self, comp, request):
self._comp = comp
-
class Test(PlacelessSetup, unittest.TestCase):
-
def testAttr(self):
- """ test container traver """
-
+ # test container traver
foo = Container()
c = Container( foo=foo )
req = Request( I, '')
-
+
T = ContainerTraverser(c, req)
self.failUnless(T.publishTraverse(req,'foo') is foo)
-
+
self.assertRaises(NotFoundError , T.publishTraverse, req ,'morebar')
def testView(self):
- """ test getting a view """
-
-
+ # test getting a view
foo = Container()
c = Container( foo=foo )
req = Request( I, '')
-
+
T = ContainerTraverser(c, req)
getService(None,'Views').provideView(IContainer, 'viewfoo', I, [View])
-
+
self.failUnless(T.publishTraverse(req,'viewfoo').__class__ is View )
self.failUnless(T.publishTraverse(req,'foo') is foo)
-
+
self.assertRaises(NotFoundError , T.publishTraverse, req, 'morebar')
self.assertRaises(NotFoundError , T.publishTraverse, req,
'@@morebar')
-
-
def test_suite():
- loader=unittest.TestLoader()
+ loader = unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
-if __name__=='__main__':
+
+if __name__ == '__main__':
unittest.TextTestRunner().run(test_suite())