Ignore:
Timestamp:
22 Mar 2012, 01:46:59 (13 years ago)
Author:
uli
Message:

Add tests for new helper function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py

    r7811 r7939  
    2525import doctest
    2626from cStringIO import StringIO
     27from zope import schema
    2728from zope.security.testing import Principal, Participation
    2829from zope.security.management import newInteraction, endInteraction
     
    238239        self.assertEqual(
    239240            helpers.file_size(StringIO('my sample content')), 17)
     241
     242class IfaceNamesTestCase(unittest.TestCase):
     243
     244    def test_iface_names(self):
     245        from zope.interface import Interface, Attribute
     246        class I1(Interface):
     247            foo = Attribute("""Some Foo""")
     248            def bar(blah):
     249                pass
     250            i1_name = schema.TextLine(title=u'i1 name')
     251        class I2(I1):
     252            baz = schema.TextLine(title=u'some baz')
     253
     254        result1 = helpers.iface_names(I2)
     255        result2 = helpers.iface_names(I1)
     256        result3 = helpers.iface_names(I2, exclude_attribs=False)
     257        result4 = helpers.iface_names(I2, exclude_methods=False)
     258        result5 = helpers.iface_names(I2, omit='i1_name')
     259        self.assertEqual(sorted(result1), ['baz', 'i1_name'])
     260        self.assertEqual(sorted(result2), ['i1_name'])
     261        self.assertEqual(sorted(result3), ['baz', 'foo', 'i1_name'])
     262        self.assertEqual(sorted(result4), ['bar', 'baz', 'i1_name'])
     263        self.assertEqual(sorted(result5), ['baz'])
     264        return
    240265
    241266def test_suite():
     
    250275        CmpFilesTestCase,
    251276        FileSizeTestCase,
     277        IfaceNamesTestCase,
    252278        ]:
    253279        suite.addTests(
Note: See TracChangeset for help on using the changeset viewer.