[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/tests - __init__.py:1.1.2.1 testTraversable.py:1.1.2.1
Martijn Pieters
mj@zope.com
Sun, 2 Dec 2001 23:39:26 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/tests
In directory cvs.zope.org:/tmp/cvs-serv8082/lib/python/Zope/App/tests
Added Files:
Tag: Zope-3x-branch
__init__.py testTraversable.py
Log Message:
Tests for Traversable code.
=== Added File Zope3/lib/python/Zope/App/tests/__init__.py ===
"""App tests"""
=== Added File Zope3/lib/python/Zope/App/tests/testTraversable.py ===
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
import unittest
from Zope.App.ITraversable import ITraversable
from Zope.App.Traversable import Traversable
from Zope.ContextWrapper import Wrapper
from Interface import verify, instancesOfObjectImplements
class C:
def __init__(self, name):
self.name = name
class TraversableTests(unittest.TestCase):
def setUp(self):
# Build up a wrapper chain
self.root = Wrapper(C('root'), None, name='')
self.folder = Wrapper(C('folder'), self.root, name='folder')
self.item = Wrapper(C('item'), self.folder, name='item')
self.tr = Traversable(self.item)
def testImplementsITraversable(self):
self.failUnless(ITraversable.isImplementedBy(self.tr))
def testVerifyInterfaces(self):
for interface in instancesOfObjectImplements(ITraversable):
verify(interface, ITraversable)
def testPhysicalRoot(self):
self.failUnless(self.tr.getPhysicalRoot() is self.root)
def testPhysicalPath(self):
self.assertEquals(self.tr.getPhysicalPath(), ('', 'folder', 'item'))
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase(TraversableTests)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())