Skip to content

Commit 316ee37

Browse files
committed
Mark unsupported tests for _json
1 parent 4b171d8 commit 316ee37

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Lib/test/test_json/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from test import support
77

88
# import json with and without accelerations
9-
cjson = support.import_fresh_module('json', fresh=['_json'])
9+
# XXX RUSTPYTHON: we don't import _json as fresh since the fresh module isn't placed
10+
# into the sys.modules cache, and therefore the vm can't recognize the _json.Scanner class
11+
cjson = support.import_fresh_module('json') #, fresh=['_json'])
1012
pyjson = support.import_fresh_module('json', blocked=['_json'])
1113
# JSONDecodeError is cached inside the _json module
12-
# XXX RustPython TODO: _json module
13-
# cjson.JSONDecodeError = cjson.decoder.JSONDecodeError = json.JSONDecodeError
14+
cjson.JSONDecodeError = cjson.decoder.JSONDecodeError = json.JSONDecodeError
1415

1516
# create two base classes that will be used by the other tests
1617
class PyTest(unittest.TestCase):
@@ -38,6 +39,7 @@ def test_pyjson(self):
3839
'json.encoder')
3940

4041
class TestCTest(CTest):
42+
@unittest.expectedFailure
4143
def test_cjson(self):
4244
self.assertEqual(self.json.scanner.make_scanner.__module__, '_json')
4345
self.assertEqual(self.json.decoder.scanstring.__module__, '_json')

Lib/test/test_json/test_decode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from collections import OrderedDict
44
from test.test_json import PyTest, CTest
55

6+
import unittest
7+
68

79
class TestDecode:
810
def test_decimal(self):
@@ -55,6 +57,7 @@ def check_keys_reuse(self, source, loads):
5557
self.assertIs(a, c)
5658
self.assertIs(b, d)
5759

60+
@unittest.skip("TODO: RUSTPYTHON: cache/memoize keys")
5861
def test_keys_reuse(self):
5962
s = '[{"a_key": 1, "b_\xe9": 2}, {"a_key": 3, "b_\xe9": 4}]'
6063
self.check_keys_reuse(s, self.loads)

Lib/test/test_json/test_speedups.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
from test.test_json import CTest
22

3+
import unittest
34

45
class BadBool:
56
def __bool__(self):
67
1/0
78

89

910
class TestSpeedups(CTest):
11+
# TODO: RUSTPYTHON
12+
@unittest.expectedFailure
1013
def test_scanstring(self):
1114
self.assertEqual(self.json.decoder.scanstring.__module__, "_json")
1215
self.assertIs(self.json.decoder.scanstring, self.json.decoder.c_scanstring)
1316

17+
# TODO: RUSTPYTHON
18+
@unittest.expectedFailure
1419
def test_encode_basestring_ascii(self):
1520
self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
1621
"_json")
@@ -38,6 +43,7 @@ def test_make_encoder(self):
3843
b"\xCD\x7D\x3D\x4E\x12\x4C\xF9\x79\xD7\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75",
3944
None)
4045

46+
@unittest.skip("TODO: RUSTPYTHON, translate the encoder to Rust")
4147
def test_bad_str_encoder(self):
4248
# Issue #31505: There shouldn't be an assertion failure in case
4349
# c_make_encoder() receives a bad encoder() argument.
@@ -59,6 +65,8 @@ def bad_encoder2(*args):
5965
with self.assertRaises(ZeroDivisionError):
6066
enc('spam', 4)
6167

68+
# TODO: RUSTPYTHON, translate the encoder to Rust
69+
@unittest.expectedFailure
6270
def test_bad_bool_args(self):
6371
def test(name):
6472
self.json.encoder.JSONEncoder(**{name: BadBool()}).encode({'a': 1})

0 commit comments

Comments
 (0)