

def assertAccessInterface(self, d):
    ' Asserts access via indexing and named property '
    self.assertEqual(d.CompareMode, 42)
    self.assertEqual(d['foo'], 1)
    self.assertEqual(d.Item['foo'], d['foo'])
    self.assertEqual(d.Item('foo'), d['foo'])
    self.assertEqual(d['bar'], 'spam foo')
    self.assertEqual(d.Item('bar'), 'spam foo')
    self.assertEqual(d['baz'], 3.14)
    self.assertEqual(d.Item('baz'), d['baz'])
    self.assertIsNone(d['asdlfkj'])
    self.assertIsNone(d.Item['asdlfkj'])
    self.assertIsNone(d.Item('asdlfkj'))
    items = iter(d)
    self.assertEqual(items[0], 'foo')
    self.assertEqual(items[1], 'bar')
    self.assertEqual(items[2], 'baz')
    self.assertEqual(items[3], 'asdlfkj')

dataset/ETHPy150Open enthought/comtypes/comtypes/test/test_dyndispatch.py Test.assertAccessInterface/original