Fix tests on Python 3.9 (apparently encoding is no-op on Python 3, and Python

always assumes utf-8 by default anyway for JSON).
This commit is contained in:
Itamar Turner-Trauring 2021-05-05 11:57:13 -04:00
parent fa0ec99052
commit 8af84b7a0c
1 changed files with 3 additions and 4 deletions

View File

@ -527,7 +527,7 @@ class JSONBytes(unittest.TestCase):
x = {u"def\N{SNOWMAN}\uFF00": 123} x = {u"def\N{SNOWMAN}\uFF00": 123}
encoded = jsonbytes.dumps_bytes(x) encoded = jsonbytes.dumps_bytes(x)
self.assertIsInstance(encoded, bytes) self.assertIsInstance(encoded, bytes)
self.assertEqual(json.loads(encoded, encoding="utf-8"), x) self.assertEqual(json.loads(encoded), x)
def test_any_bytes_unsupported_by_default(self): def test_any_bytes_unsupported_by_default(self):
"""By default non-UTF-8 bytes raise error.""" """By default non-UTF-8 bytes raise error."""
@ -554,9 +554,8 @@ class JSONBytes(unittest.TestCase):
expected, expected,
) )
self.assertEqual( self.assertEqual(
json.loads(jsonbytes.dumps(o, any_bytes=True), json.loads(jsonbytes.dumps(o, any_bytes=True)),
encoding="utf-8"), expected
expected,
) )