https://github.com/python/cpython/commit/5380589615515fa9e2c48820073a3fd8e32a930d
commit: 5380589615515fa9e2c48820073a3fd8e32a930d
branch: main
author: Dominic H. <[email protected]>
committer: tomasr8 <[email protected]>
date: 2026-07-19T13:58:06+02:00
summary:
Add test for explicit `cls` argument bypassing default JSON decoder (#154094)
* Add test for skipped `cls=None` case
* Fix lint
* Add new line between classes
files:
M Lib/test/test_json/test_decode.py
diff --git a/Lib/test/test_json/test_decode.py
b/Lib/test/test_json/test_decode.py
index 1d51fb2de0e69e4..6d05ef8f8eb0918 100644
--- a/Lib/test/test_json/test_decode.py
+++ b/Lib/test/test_json/test_decode.py
@@ -1,4 +1,5 @@
import decimal
+import unittest.mock
from io import StringIO
from collections import OrderedDict
from test.test_json import PyTest, CTest
@@ -155,6 +156,15 @@ def test_limit_int(self):
with self.assertRaises(ValueError):
self.loads('1' * (maxdigits + 1))
+ def test_explicit_cls_skips_json_decoder_default(self):
+ class CustomDecoder:
+ pass
+
+ with unittest.mock.patch.object(
+ CustomDecoder, 'decode', create=True) as mock_decode:
+ self.loads('{}', cls=CustomDecoder)
+ mock_decode.assert_called_once()
+
class TestPyDecode(TestDecode, PyTest): pass
class TestCDecode(TestDecode, CTest): pass
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]