def test_hashable(self):
a = grammar.TypeExpression('X')
b = grammar.TypeExpression('Y', fields=(a,))
c = grammar.TypeExpression('Y', fields=(a,))
d = grammar.TypeExpression('Z', predicate=grammar.Predicate("stuff"))
self.assertIsInstance(a, collections.Hashable)
# There really shouldn't be a collision between these:
self.assertNotEqual(hash(a), hash(d))
self.assertEqual(b, c)
self.assertEqual(hash(b), hash(c))
# TODO: Test dictionaries work well
评论列表
文章目录