[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Introspector/tests - __init__.py:1.1.2.1 testIntrospector.py:1.1.2.1
Gary Poster
garyposter@earthlink.net
Sat, 23 Mar 2002 18:04:34 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Introspector/tests
In directory cvs.zope.org:/tmp/cvs-serv27748/Introspector/tests
Added Files:
Tag: Zope-3x-branch
__init__.py testIntrospector.py
Log Message:
Added Introspector, changed ofs.zcml to include; introspector links do not work due to no implementation for introspecting interfaces
=== Added File Zope3/lib/python/Zope/App/OFS/Introspector/tests/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/Introspector/tests/testIntrospector.py ===
##############################################################################
#
# 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
#
##############################################################################
"""
Revision information:
$Id: testIntrospector.py,v 1.1.2.1 2002/03/23 23:04:33 poster Exp $
"""
from unittest import TestCase, TestSuite, main, makeSuite
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
from Zope.App.OFS.Introspector.Introspector import Introspector
# 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.
from Interface import Interface
from Interface.Implements import implements
class IStupid(Interface):
def drool():
"""...drool..."""
class Stupid:
"""This is my stupid doc string"""
def drool(self):
pass
implements(Stupid, IStupid)
class Test(CleanUp, TestCase):
def testDocString(self):
intro=Introspector(Stupid())
assert intro.getDocString()=="This is my stupid doc string"
def testGetInterfaces(self):
intro=Introspector(Stupid()).getInterfaces()
assert (len(intro)==1 and intro[0]==IStupid)
def testGetName(self):
nm=Introspector(Stupid()).getName()
assert nm=="Stupid"
def testGetInterfaceNames(self):
iname = Introspector(Stupid()).getInterfaceNames()[0].split(".")
i = __import__(iname[-2], globals(), locals(), iname[:-2])
assert i.IStupid==IStupid
def test_suite():
return TestSuite((
makeSuite(Test),
))
if __name__=='__main__':
main(defaultTest='test_suite')