def testUpdate(self): new = utils.DictionaryContainer(items=self.dict, restrict=self.keys) new._update({'A': 7}) self.assertTrue('A' in new) self.assertEqual(new['A'], 7) self.assertRaises(utils.ItemNotFoundError, new._update, {'Z': 0})
def setUp(self): super(TestDictionaryContainer, self).setUp() self.dict = utils.OrderedDict([('A', 1), ('B', 2)]) self.keys = ('A', 'B', 'C', 'D', 'Z') self.new = utils.DictionaryContainer self.test = utils.DictionaryContainer(items=self.dict, restrict=self.keys)
def _children(self): return utils.DictionaryContainer(dictitems)
def testSet(self): new = utils.DictionaryContainer(items=self.dict, restrict=self.keys) new._set({'Z': 6}) self.assertTrue('Z' in new) self.assertFalse('A' in new)
def testConstructor(self): new = utils.DictionaryContainer(items=self.dict, restrict=self.keys) self.assertEqual(dict(new), dict(self.dict)) self.assertEqual(list(new), list(self.dict)) # True if the dictionary is ordered self.assertEqual(new.length, len(self.dict)) self.assertRaises(utils.InvalidKeyError, self.new, items={'X': 1}, restrict=self.keys)