Esempio n. 1
0
 def test_owned_dict_pop_3_arguments_raises(self):
     owner = Owner()
     owned_dict = OwnedDict({'a': 1, 'b': 2, 'c': 3})
     owned_dict.owner = owner
     with self.assertRaisesRegex(TypeError, ('pop expected at most 2 '
                                             'arguments, got 3')):
         owned_dict.pop(1, 2, 3)
Esempio n. 2
0
 def test_owned_dict_pop_zero_arguments_raises(self):
     owner = Owner()
     owned_dict = OwnedDict({'a': 2, 'b': 3})
     owned_dict.owner = owner
     with self.assertRaisesRegex(TypeError, ('pop expected at least 1 '
                                             'argument, got 0')):
         owned_dict.pop()
Esempio n. 3
0
 def test_owned_dict_get_notified_thru_pop_with_default_no_key(self):
     owner = Owner()
     owned_dict = OwnedDict({'a': 2, 'b': 3})
     owned_dict.owner = owner
     owned_dict.pop('z', 4)
     self.assertEqual(owned_dict, {'a': 2, 'b': 3})
     self.assertEqual(owner.add_records, [])
     self.assertEqual(owner.del_records, [])
Esempio n. 4
0
 def test_owned_dict_get_notified_thru_pop(self):
     owner = Owner()
     owned_dict = OwnedDict({'a': 2, 'b': 3})
     owned_dict.owner = owner
     owned_dict.pop('a')
     self.assertEqual(owned_dict, {'b': 3})
     self.assertEqual(owner.add_records, [])
     self.assertEqual(owner.del_records, [DelRecord(owned_dict, 2)])
Esempio n. 5
0
 def test_owned_dict_pop_undefined_key_raises(self):
     owner = Owner()
     owned_dict = OwnedDict({'a': 2, 'b': 3})
     owned_dict.owner = owner
     with self.assertRaisesRegex(KeyError, 'z'):
         owned_dict.pop('z')