def test_from_json_object_hook(self): raw_data = (b'{"a":2,"b":"four","__traits_version__":"' + version.encode('utf-8') + b'"}') data = from_json(raw_data, object_hook=object_hook) self.assertIsInstance(data, ExampleObject) self.assertEqual(data.a, 2) self.assertEqual(data.b, 'four') self.assertEqual(data.c, 'three')
def test_from_json(self): raw_data = b'{"a":1,"b":"two"}' data = from_json(raw_data) self.assertEqual(data, {'a': 1, 'b': 'two'})