mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Update test_json from 3.14.3
This commit is contained in:
committed by
Jeong, YunWon
parent
3bd061ef5a
commit
f73df6a102
2
Lib/test/test_json/__init__.py
vendored
2
Lib/test/test_json/__init__.py
vendored
@@ -41,7 +41,7 @@ class TestPyTest(PyTest):
|
||||
'json.encoder')
|
||||
|
||||
class TestCTest(CTest):
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_cjson(self):
|
||||
self.assertEqual(self.json.scanner.make_scanner.__module__, '_json')
|
||||
self.assertEqual(self.json.decoder.scanstring.__module__, '_json')
|
||||
|
||||
8
Lib/test/test_json/test_decode.py
vendored
8
Lib/test/test_json/test_decode.py
vendored
@@ -4,7 +4,7 @@ from collections import OrderedDict
|
||||
from test.test_json import PyTest, CTest
|
||||
from test import support
|
||||
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
|
||||
class TestDecode:
|
||||
@@ -18,7 +18,7 @@ class TestDecode:
|
||||
self.assertIsInstance(rval, float)
|
||||
self.assertEqual(rval, 1.0)
|
||||
|
||||
@unittest.skip('TODO: RUSTPYTHON; called `Result::unwrap()` on an `Err` value: ParseFloatError { kind: Invalid }')
|
||||
@unittest.skip("TODO: RUSTPYTHON; called `Result::unwrap()` on an `Err` value: ParseFloatError { kind: Invalid }")
|
||||
def test_nonascii_digits_rejected(self):
|
||||
# JSON specifies only ascii digits, see gh-125687
|
||||
for num in ["1\uff10", "0.\uff10", "0e\uff10"]:
|
||||
@@ -135,9 +135,7 @@ class TestDecode:
|
||||
|
||||
|
||||
class TestPyDecode(TestDecode, PyTest): pass
|
||||
|
||||
class TestCDecode(TestDecode, CTest):
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_limit_int(self):
|
||||
return super().test_limit_int()
|
||||
|
||||
6
Lib/test/test_json/test_default.py
vendored
6
Lib/test/test_json/test_default.py
vendored
@@ -1,7 +1,8 @@
|
||||
import collections
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
from test.test_json import PyTest, CTest
|
||||
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
|
||||
class TestDefault:
|
||||
def test_default(self):
|
||||
@@ -9,8 +10,7 @@ class TestDefault:
|
||||
self.dumps(type, default=repr),
|
||||
self.dumps(repr(type)))
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_bad_default(self):
|
||||
def default(obj):
|
||||
if obj is NotImplemented:
|
||||
|
||||
8
Lib/test/test_json/test_fail.py
vendored
8
Lib/test/test_json/test_fail.py
vendored
@@ -1,7 +1,7 @@
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
from test.test_json import PyTest, CTest
|
||||
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
# 2007-10-05
|
||||
JSONDOCS = [
|
||||
# https://json.org/JSON_checker/test/fail1.json
|
||||
@@ -239,9 +239,7 @@ class TestFail:
|
||||
(line, col, idx))
|
||||
|
||||
class TestPyFail(TestFail, PyTest): pass
|
||||
|
||||
class TestCFail(TestFail, CTest):
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_failures(self):
|
||||
return super().test_failures()
|
||||
|
||||
27
Lib/test/test_json/test_recursion.py
vendored
27
Lib/test/test_json/test_recursion.py
vendored
@@ -1,7 +1,7 @@
|
||||
from test import support
|
||||
from test.test_json import PyTest, CTest
|
||||
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
|
||||
class JSONTestObject:
|
||||
@@ -70,13 +70,12 @@ class TestRecursion:
|
||||
self.fail("didn't raise ValueError on default recursion")
|
||||
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.skip('TODO: RUSTPYTHON; crashes')
|
||||
# TODO: RUSTPYHTON; needs to upgrade test.support to 3.14 above
|
||||
# @support.skip_emscripten_stack_overflow()
|
||||
# @support.skip_wasi_stack_overflow()
|
||||
@unittest.skip("TODO: RUSTPYTHON; crashes")
|
||||
@support.skip_if_unlimited_stack_size
|
||||
@support.skip_emscripten_stack_overflow()
|
||||
@support.skip_wasi_stack_overflow()
|
||||
def test_highly_nested_objects_decoding(self):
|
||||
very_deep = 200000
|
||||
very_deep = 500_000
|
||||
# test that loading highly-nested objects doesn't segfault when C
|
||||
# accelerations are used. See #12017
|
||||
with self.assertRaises(RecursionError):
|
||||
@@ -89,14 +88,14 @@ class TestRecursion:
|
||||
with support.infinite_recursion():
|
||||
self.loads('[' * very_deep + '1' + ']' * very_deep)
|
||||
|
||||
# TODO: RUSTPYHTON; needs to upgrade test.support to 3.14 above
|
||||
# @support.skip_wasi_stack_overflow()
|
||||
# @support.skip_emscripten_stack_overflow()
|
||||
@support.skip_if_unlimited_stack_size
|
||||
@support.skip_wasi_stack_overflow()
|
||||
@support.skip_emscripten_stack_overflow()
|
||||
@support.requires_resource('cpu')
|
||||
def test_highly_nested_objects_encoding(self):
|
||||
# See #12051
|
||||
l, d = [], {}
|
||||
for x in range(200_000):
|
||||
for x in range(500_000):
|
||||
l, d = [l], {'k':d}
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion(5000):
|
||||
@@ -105,9 +104,9 @@ class TestRecursion:
|
||||
with support.infinite_recursion(5000):
|
||||
self.dumps(d)
|
||||
|
||||
# TODO: RUSTPYHTON; needs to upgrade test.support to 3.14 above
|
||||
# @support.skip_emscripten_stack_overflow()
|
||||
# @support.skip_wasi_stack_overflow()
|
||||
@support.skip_if_unlimited_stack_size
|
||||
@support.skip_emscripten_stack_overflow()
|
||||
@support.skip_wasi_stack_overflow()
|
||||
def test_endless_recursion(self):
|
||||
# See #12051
|
||||
class EndlessJSONEncoder(self.json.JSONEncoder):
|
||||
|
||||
4
Lib/test/test_json/test_scanstring.py
vendored
4
Lib/test/test_json/test_scanstring.py
vendored
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from test.test_json import PyTest, CTest
|
||||
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
|
||||
class TestScanstring:
|
||||
@@ -144,7 +144,7 @@ class TestScanstring:
|
||||
with self.assertRaises(self.JSONDecodeError, msg=s):
|
||||
scanstring(s, 1, True)
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_overflow(self):
|
||||
with self.assertRaises(OverflowError):
|
||||
self.json.decoder.scanstring("xxx", sys.maxsize+1)
|
||||
|
||||
40
Lib/test/test_json/test_speedups.py
vendored
40
Lib/test/test_json/test_speedups.py
vendored
@@ -1,6 +1,6 @@
|
||||
from test.test_json import CTest
|
||||
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
|
||||
class BadBool:
|
||||
@@ -40,7 +40,7 @@ class TestEncode(CTest):
|
||||
b"\xCD\x7D\x3D\x4E\x12\x4C\xF9\x79\xD7\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75",
|
||||
None)
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: 'NoneType' object is not callable
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: 'NoneType' object is not callable
|
||||
def test_bad_str_encoder(self):
|
||||
# Issue #31505: There shouldn't be an assertion failure in case
|
||||
# c_make_encoder() receives a bad encoder() argument.
|
||||
@@ -62,7 +62,7 @@ class TestEncode(CTest):
|
||||
with self.assertRaises(ZeroDivisionError):
|
||||
enc('spam', 4)
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_bad_markers_argument_to_encoder(self):
|
||||
# https://bugs.python.org/issue45269
|
||||
with self.assertRaisesRegex(
|
||||
@@ -72,7 +72,7 @@ class TestEncode(CTest):
|
||||
self.json.encoder.c_make_encoder(1, None, None, None, ': ', ', ',
|
||||
False, False, False)
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON; ZeroDivisionError not raised by test
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON; ZeroDivisionError not raised by test
|
||||
def test_bad_bool_args(self):
|
||||
def test(name):
|
||||
self.json.encoder.JSONEncoder(**{name: BadBool()}).encode({'a': 1})
|
||||
@@ -85,3 +85,35 @@ class TestEncode(CTest):
|
||||
def test_unsortable_keys(self):
|
||||
with self.assertRaises(TypeError):
|
||||
self.json.encoder.JSONEncoder(sort_keys=True).encode({'a': 1, 1: 'a'})
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: 'NoneType' object is not callable
|
||||
def test_current_indent_level(self):
|
||||
enc = self.json.encoder.c_make_encoder(
|
||||
markers=None,
|
||||
default=str,
|
||||
encoder=self.json.encoder.c_encode_basestring,
|
||||
indent='\t',
|
||||
key_separator=': ',
|
||||
item_separator=', ',
|
||||
sort_keys=False,
|
||||
skipkeys=False,
|
||||
allow_nan=False)
|
||||
expected = (
|
||||
'[\n'
|
||||
'\t"spam", \n'
|
||||
'\t{\n'
|
||||
'\t\t"ham": "eggs"\n'
|
||||
'\t}\n'
|
||||
']')
|
||||
self.assertEqual(enc(['spam', {'ham': 'eggs'}], 0)[0], expected)
|
||||
self.assertEqual(enc(['spam', {'ham': 'eggs'}], -3)[0], expected)
|
||||
expected2 = (
|
||||
'[\n'
|
||||
'\t\t\t\t"spam", \n'
|
||||
'\t\t\t\t{\n'
|
||||
'\t\t\t\t\t"ham": "eggs"\n'
|
||||
'\t\t\t\t}\n'
|
||||
'\t\t\t]')
|
||||
self.assertEqual(enc(['spam', {'ham': 'eggs'}], 3)[0], expected2)
|
||||
self.assertRaises(TypeError, enc, ['spam', {'ham': 'eggs'}], 3.0)
|
||||
self.assertRaises(TypeError, enc, ['spam', {'ham': 'eggs'}])
|
||||
|
||||
13
Lib/test/test_json/test_tool.py
vendored
13
Lib/test/test_json/test_tool.py
vendored
@@ -6,22 +6,14 @@ import unittest
|
||||
import subprocess
|
||||
|
||||
from test import support
|
||||
from test.support import force_not_colorized, os_helper
|
||||
from test.support import force_colorized, force_not_colorized, os_helper
|
||||
from test.support.script_helper import assert_python_ok
|
||||
|
||||
from _colorize import get_theme
|
||||
|
||||
# XXX: RUSTPYTHON; force_colorized not available in test.support
|
||||
def force_colorized(func):
|
||||
"""Placeholder decorator for RustPython - force_colorized not available."""
|
||||
import functools
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
raise unittest.SkipTest("TODO: RUSTPYTHON; force_colorized not available")
|
||||
return wrapper
|
||||
|
||||
|
||||
@support.requires_subprocess()
|
||||
@support.skip_if_pgo_task
|
||||
class TestMain(unittest.TestCase):
|
||||
data = """
|
||||
|
||||
@@ -328,6 +320,7 @@ class TestMain(unittest.TestCase):
|
||||
|
||||
|
||||
@support.requires_subprocess()
|
||||
@support.skip_if_pgo_task
|
||||
class TestTool(TestMain):
|
||||
module = 'json.tool'
|
||||
|
||||
|
||||
8
Lib/test/test_json/test_unicode.py
vendored
8
Lib/test/test_json/test_unicode.py
vendored
@@ -2,7 +2,7 @@ import codecs
|
||||
from collections import OrderedDict
|
||||
from test.test_json import PyTest, CTest
|
||||
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
|
||||
|
||||
|
||||
class TestUnicode:
|
||||
@@ -137,19 +137,15 @@ class TestUnicode:
|
||||
|
||||
|
||||
class TestPyUnicode(TestUnicode, PyTest): pass
|
||||
|
||||
class TestCUnicode(TestUnicode, CTest):
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_ascii_non_printable_encode(self):
|
||||
return super().test_ascii_non_printable_encode()
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.skip("TODO: RUSTPYTHON; panics with 'str has surrogates'")
|
||||
def test_single_surrogate_decode(self):
|
||||
return super().test_single_surrogate_decode()
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.skip("TODO: RUSTPYTHON; panics with 'str has surrogates'")
|
||||
def test_single_surrogate_encode(self):
|
||||
return super().test_single_surrogate_encode()
|
||||
|
||||
Reference in New Issue
Block a user