def test_conv_dict_to_odict(self): d = { "a": { '1': 'x' }, "b": { "1": 'x', "2": 'o' }, "c": { }, "d": { "5": 'x' } } odict_d = conv_dict_to_odict(d) assert_d = OrderedDict( ( ("a", OrderedDict((('1', 'x'),))), ("b", OrderedDict((('1', 'x'), ('2', 'o')))), ("c", OrderedDict()), ("d", OrderedDict((('5', 'x'),))), ), ) self.assertDictEqual(odict_d, assert_d)
def convert(self, d): return conv_dict_to_odict(d, first_sort=lambda items: sorted(items, key=lambda i: int(i[0])))
def convert(self, d): return conv_dict_to_odict(d)