def test_to_json_file(self): d = IODict({ 'x': 7, 'y': 8, 'z': 9, 'a': 1, 'b': 2, 'c': 3, }) filepath = self.output_path('test_to_json_file.json') d.to_json(filepath=filepath, sort_keys=True) self.assertFileExists(filepath) self.assertEqual(d, IODict.from_json(filepath))
def test_to_json(self): d = IODict({ 'x': 7, 'y': 8, 'z': 9, 'a': 1, 'b': 2, 'c': 3, }) s = d.to_json(sort_keys=True) self.assertEqual(s, '{"a": 1, "b": 2, "c": 3, "x": 7, "y": 8, "z": 9}')