mirror of
https://github.com/python/cpython
synced 2026-11-13 11:36:56 +03:00
Test `object_hook` and pickleability of some JSON components (GH-154155)
(cherry picked from commit d333e5aa59)
Co-authored-by: David <slavicek.david29@gmail.com>
14 lines
417 B
Python
14 lines
417 B
Python
import json
|
|
import pickle
|
|
import unittest
|
|
|
|
class TestPickleable(unittest.TestCase):
|
|
def test_json_decode_error_is_pickleable(self):
|
|
e = json.JSONDecodeError(msg="abc", doc="def", pos=7)
|
|
|
|
pickled = pickle.dumps(e)
|
|
unpickled = pickle.loads(pickled)
|
|
|
|
self.assertEqual(unpickled.msg, e.msg)
|
|
self.assertEqual(unpickled.doc, e.doc)
|
|
self.assertEqual(unpickled.pos, e.pos)
|