[3.15] Add test for explicit `cls` argument bypassing default JSON decoder (GH-154094) (#154112)

tomasr8 <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/9f7c44fc7bd3fcd041dd9d6daee7801131ad01a1
commit: 9f7c44fc7bd3fcd041dd9d6daee7801131ad01a1
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: tomasr8 <[email protected]>
date: 2026-07-19T12:28:27Z
summary:

[3.15] Add test for explicit `cls` argument bypassing default JSON decoder (GH-154094) (#154112)

Add test for explicit `cls` argument bypassing default JSON decoder (GH-154094)

* Add test for skipped `cls=None` case

* Fix lint

* Add new line between classes
(cherry picked from commit 5380589615515fa9e2c48820073a3fd8e32a930d)

Co-authored-by: Dominic H <[email protected]>

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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.