bpo-45269: test wrong markers type to c_make_encoder (GH-28540)

This commit is contained in:
Nikita Sobolev 2021-09-29 00:18:00 +03:00 committed by GitHub
parent 4f05f15d7b
commit e046aabbe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -59,6 +59,15 @@ class TestEncode(CTest):
with self.assertRaises(ZeroDivisionError):
enc('spam', 4)
def test_bad_markers_argument_to_encoder(self):
# https://bugs.python.org/issue45269
with self.assertRaisesRegex(
TypeError,
r'make_encoder\(\) argument 1 must be dict or None, not int',
):
self.json.encoder.c_make_encoder(1, None, None, None, ': ', ', ',
False, False, False)
def test_bad_bool_args(self):
def test(name):
self.json.encoder.JSONEncoder(**{name: BadBool()}).encode({'a': 1})

View file

@ -0,0 +1 @@
Cover case when invalid ``markers`` type is supplied to ``c_make_encoder``.