[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Introspector/tests - testIntrospector.py:1.3.6.1
Deb
dhazarika@zeomega.com
Tue, 29 Oct 2002 03:46:19 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Introspector/tests
In directory cvs.zope.org:/tmp/cvs-serv5495
Modified Files:
Tag: Zope3-Bangalore-TTW-Branch
testIntrospector.py
Log Message:
Test for introspector fixed
=== Zope3/lib/python/Zope/App/OFS/Introspector/tests/testIntrospector.py 1.3 => 1.3.6.1 ===
--- Zope3/lib/python/Zope/App/OFS/Introspector/tests/testIntrospector.py:1.3 Wed Jul 17 12:54:18 2002
+++ Zope3/lib/python/Zope/App/OFS/Introspector/tests/testIntrospector.py Tue Oct 29 03:46:18 2002
@@ -15,49 +15,74 @@
Revision information:
$Id$
-"""
-
-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
+"""
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)
+from unittest import TestCase, TestSuite, main, makeSuite
+from Zope.Testing.CleanUp import CleanUp
+from Zope.Exceptions import DuplicationError, NotFoundError
+from Zope.Publisher.Browser.BrowserRequest import TestRequest
+from Zope.App.OFS.Introspector.Introspector import Introspector
+from TestClass import TestClass, ITestClass, BaseTestClass, I, I2, I3
-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
+class Test(CleanUp, TestCase):
+ """Test Introspector.
+ """
+
+ def testIntrospector(self):
+ """
+ """
+ ints = Introspector(ITestClass)
+ self.assertEqual(ints.isInterface(), 1)
+
+ ints = Introspector(TestClass())
+ self.assertEqual(ints.isInterface(), 1)
+ request = {}
+ ints.setRequest(request)
+ self.assertEqual(ints.getClass(), 'TestClass')
+
+ ints = Introspector(TestClass)
+ self.assertEqual(ints.isInterface(), 0)
+ request['PATH_INFO'] = '++module++Zope.App.OFS.Introspector.tests.TestClass.TestClass'
+ ints.setRequest(request)
+ self.assertEqual(ints.getClass(), 'TestClass')
+ self.assertEqual(ints.getBaseClassNames(), ['TestClass.BaseTestClass'])
+ self.assertEqual(ints.getModule(), 'TestClass')
+ self.assertEqual(ints.getDocString(), "This is my stupid doc string")
+ self.assertEqual(ints.getInterfaces(), (ITestClass,))
+ self.assertEqual(ints.getInterfaceNames(), ['TestClass.ITestClass'])
+ self.assertEqual(ints.getExtends(), (BaseTestClass,))
+
+ ints = Introspector(I3)
+ self.assertEqual(ints.isInterface(), 1)
+ request['PATH_INFO'] = '++module++Zope.App.OFS.Introspector.tests.TestClass.I3'
+ ints.setRequest(request)
+ self.assertEqual(ints.getModule(), 'TestClass')
+ self.assertEqual(ints.getExtends(), (I, I2, ))
+ self.assertEqual(ints.getDocString(), "This is dummy doc string")
+ Iname = 'I3'
+ bases = ['TestClass.I', 'TestClass.I2']
+ desc = 'This is dummy doc string'
+ m1_name = 'one'
+ m1_signature = '(param)'
+ m1_desc = 'method one'
+ m2_name = 'two'
+ m2_signature = '(param1, param2)'
+ m2_desc = 'method two'
+ methods = [(m1_name, m1_signature, m1_desc),(m2_name, m2_signature, m2_desc),]
+ attr_name1 = 'testAttribute1'
+ attr_desc1 = 'This is a dummy attribute.'
+ attr_name2 = 'testAttribute2'
+ attr_desc2 = 'This is a dummy attribute.'
+ attributes = [(attr_name1, attr_desc1), (attr_name2, attr_desc2), ]
+ details = [Iname, bases, desc, methods, attributes]
+
+ self.assertEqual(ints.getInterfaceDetails(), details)
def test_suite():
- return makeSuite(Test)
+ return TestSuite((makeSuite(Test),))
if __name__=='__main__':
main(defaultTest='test_suite')
+