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

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

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

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 2250af964c022bf..e46f19712953546 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
@@ -130,6 +131,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.