Esempio n. 1
0
    def test_isInterface(self):
        ints = Introspector(ITestClass)
        self.assertEqual(ints.isInterface(), 1)

        ints = Introspector(TestClass())
        self.assertEqual(ints.isInterface(), 0)

        ints = Introspector(WeirdClass())
        self.assertEqual(ints.isInterface(), 0)

        verifyObject(IIntrospector, ints)
Esempio n. 2
0
 def testIntrospectorOnInterface(self):
     request = {}
     ints = Introspector(I3)
     self.assertEqual(ints.isInterface(), 1)
     request['PATH_INFO'] = (
         '++module++zope.app.introspector.tests.test_introspector.I3')
     ints.setRequest(request)
     self.assertEqual(
         ints.getModule(),
         'zope.app.introspector.tests.test_introspector')
     self.assertEqual(ints.getExtends(), (I, I2, ))
     self.assertEqual(
         ints.getDocString(),
         "This is dummy doc string")
     Iname = 'I3'
     bases = ['zope.app.introspector.tests.test_introspector.I',
              'zope.app.introspector.tests.test_introspector.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)
Esempio n. 3
0
    def testIntrospectorOnClass(self):
        request = {}
        ints = Introspector(TestClass)
        self.assertEqual(ints.isInterface(), 0)
        request['PATH_INFO'] = (
            '++module++zope.app.tests.test_introspector.TestClass')
        ints.setRequest(request)
        self.assertEqual(ints.getClass(), 'TestClass')

        self.assertEqual(
            ints.getBaseClassNames(),
            ['zope.app.introspector.tests.test_introspector.BaseTestClass'])
        self.assertEqual(
            ints.getModule(),
            'zope.app.introspector.tests.test_introspector')
        self.assertEqual(ints.getDocString(), "This is my stupid doc string")
        self.assertEqual(ints.getInterfaces(), (ITestClass,))
        self.assertEqual(
            ints.getInterfaceNames(),
            ['zope.app.introspector.tests.test_introspector.ITestClass'])
        self.assertEqual(ints.getExtends(), (BaseTestClass,))