Ejemplo n.º 1
0
 def test_stack(self):
     td = TemplateDict()
     td._push({'one': 1, 'two': 2})
     td._push(object())
     td._push({'two': 22, 'three': 3})
     td._push({'four': None})
     self.assertTrue('three' in td)
     self.assertEqual(td.getitem('three'), 3)
     self.assertTrue('two' in td)
     self.assertEqual(td.getitem('two'), 22)
     self.assertRaises(TypeError, td.__contains__, 'one')
     self.assertRaises(TypeError, td.getitem, 'one')
     self.assertTrue('four' in td)
     self.assertEqual(td.getitem('four'), None)
 def test_stack(self):
     td = TemplateDict()
     td._push({'one': 1, 'two': 2})
     td._push(object())
     td._push({'two': 22, 'three': 3})
     td._push({'four': None})
     self.assertTrue('three' in td)
     self.assertEqual(td.getitem('three'), 3)
     self.assertTrue('two' in td)
     self.assertEqual(td.getitem('two'), 22)
     self.assertRaises(TypeError, td.__contains__, 'one')
     self.assertRaises(TypeError, td.getitem, 'one')
     self.assertTrue('four' in td)
     self.assertEqual(td.getitem('four'), None)
Ejemplo n.º 3
0
 def test_push_pop(self):
     td = TemplateDict()
     td._push('foo')
     td._push('bar')
     self.assertEqual(len(td), 6)
     self.assertEqual(td[0], 'b')
     self.assertEqual(td[:], 'bar')
     self.assertEqual(td.getitem(-1), 'r')
     self.assertTrue(td() is None)
     self.assertEqual(td._pop(1), 'bar')
     self.assertEqual(len(td), 3)
     self.assertEqual(td[:], 'foo')
 def test_push_pop(self):
     td = TemplateDict()
     td._push('foo')
     td._push('bar')
     self.assertEqual(len(td), 6)
     self.assertEqual(td[0], 'b')
     self.assertEqual(td[:], 'bar')
     self.assertEqual(td.getitem(-1), 'r')
     self.assertTrue(td() is None)
     self.assertEqual(td._pop(1), 'bar')
     self.assertEqual(len(td), 3)
     self.assertEqual(td[:], 'foo')