Beispiel #1
0
 def test_setitem_TypeError(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     with self.assertRaises(TypeError) as context:
         rgb['grey'] = 'pewter'
     self.assertEqual(
         str(context.exception),
         "'FixedKeyMap' object does not support new item assignment")
Beispiel #2
0
 def test_del_TypeError(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     with self.assertRaises(TypeError) as context:
         del rgb['red']
     self.assertEqual(
         str(context.exception),
         "'FixedKeyMap' object does not support item deletion")
Beispiel #3
0
 def test_create(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     self.assertIsInstance(rgb, FixedKeyMap)
     self.assertIn('red', rgb)
     self.assertIn('green', rgb)
     self.assertIn('blue', rgb)
Beispiel #4
0
 def test_iter(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     self.assertEqual(frozenset(iter(rgb)),
                      frozenset(['red', 'green', 'blue']))
Beispiel #5
0
 def test_len(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     self.assertEqual(len(rgb), 3)
Beispiel #6
0
 def test_setitem(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     rgb['blue'] = 'topaz'
     self.assertEqual(rgb['blue'], 'topaz')
Beispiel #7
0
 def test_getitem_KeyError(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     with self.assertRaises(KeyError) as context:
         rgb['grey']
     self.assertEqual(str(context.exception), "'grey'")
Beispiel #8
0
 def test_getitem(self):
     rgb = FixedKeyMap(red='rouge', green='forest', blue='azul')
     self.assertEqual(rgb['red'], 'rouge')