예제 #1
0
 def test_empty(self):
     td = TemplateDict()
     self.assertEqual(len(td), 0)
     self.assertEqual(td.level, 0)
     self.assertRaises(AttributeError, getattr, td, 'foo')
     self.assertFalse(td.has_key('foo'))  # NOQA
     self.assertFalse('foo' in td)
     self.assertFalse(td.has_key('level'))  # NOQA
     self.assertFalse('level' in td)
     self.assertRaises(KeyError, td.getitem, 0)
     self.assertFalse(0 in td)
     with self.assertRaises(KeyError):
         td['foo']
     self.assertTrue(td() is None)
 def test_empty(self):
     td = TemplateDict()
     self.assertEqual(len(td), 0)
     self.assertEqual(td.level, 0)
     self.assertRaises(AttributeError, getattr, td, 'foo')
     self.assertFalse(td.has_key('foo'))  # NOQA
     self.assertFalse('foo' in td)
     self.assertFalse(td.has_key('level'))  # NOQA
     self.assertFalse('level' in td)
     self.assertRaises(KeyError, td.getitem, 0)
     self.assertFalse(0 in td)
     with self.assertRaises(KeyError):
         td['foo']
     self.assertTrue(td() is None)
예제 #3
0
 def test_attr(self):
     td = TemplateDict()
     td.foo = 1
     td.bar = 2
     td.baz = None
     self.assertEqual(len(td), 0)
     self.assertRaises(KeyError, td.getitem, 0)
     self.assertFalse(td.has_key('foo'))  # NOQA
     self.assertFalse('foo' in td)
     self.assertEqual(td.foo, 1)
     self.assertEqual(td.bar, 2)
     self.assertEqual(td.baz, None)
 def test_attr(self):
     td = TemplateDict()
     td.foo = 1
     td.bar = 2
     td.baz = None
     self.assertEqual(len(td), 0)
     self.assertRaises(KeyError, td.getitem, 0)
     self.assertFalse(td.has_key('foo'))  # NOQA
     self.assertFalse('foo' in td)
     self.assertEqual(td.foo, 1)
     self.assertEqual(td.bar, 2)
     self.assertEqual(td.baz, None)