def test_int(self): udict = unicode_defaultdict(int) self.assertEqual(udict[1],0) self.assertEqual(udict['a'], 0) udict['à'] += 1 self.assertEqual(udict['a'], 1) self.assertEqual(udict['à'], 1)
def test_obj(self): class test(object): def __init__(self): self.val = 0 udict = unicode_defaultdict(test) self.assertEqual(udict[1].val, 0) self.assertEqual(udict['a'].val, 0) udict['à'].val = 1 self.assertEqual(udict['a'].val, 1) self.assertEqual(udict['à'].val, 1)