def test_iter(self): ctx = Contexts() ctx.add(Context('foo')) # includes default contexts self.assertEqual(['default', 'foo', 'null'], sorted(list(ctx)))
def test_contains(self): ctx = Contexts() ctx.add(Context('foo')) self.assertTrue('foo' in ctx) self.assertFalse('bar' in ctx)
def test_keyerror(self): ctx = Contexts() ctx.add(Context('foo')) with self.assertRaises(KeyError): ctx['bar']