コード例 #1
0
    def test_bad_index(self):
        sot = schema.AnyIndexDict('*')

        ex = self.assertRaises(KeyError, sot.__getitem__, 'foo')

        # the following test is not interesting
        self.assertEqual("'Invalid key foo'", str(ex))
コード例 #2
0
    def test_basic(self):
        sot = schema.AnyIndexDict('*')

        self.assertIsInstance(sot, collections.Mapping)

        self.assertEqual('*', sot.value)
        self.assertEqual('*', sot[1])
        self.assertEqual('*', sot[2])
        self.assertEqual('*', sot['*'])

        for a in sot:
            self.assertEqual('*', a)

        self.assertEqual(1, len(sot))