MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_scanstring

Method test_scanstring

Lib/test/test_json/test_scanstring.py:8–88  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6
7class TestScanstring:
8 def test_scanstring(self):
9 scanstring = self.json.decoder.scanstring
10 self.assertEqual(
11 scanstring('"z\U0001d120x"', 1, True),
12 ('z\U0001d120x', 5))
13
14 self.assertEqual(
15 scanstring('"\\u007b"', 1, True),
16 ('{', 8))
17
18 self.assertEqual(
19 scanstring('"A JSON payload should be an object or array, not a string."', 1, True),
20 ('A JSON payload should be an object or array, not a string.', 60))
21
22 self.assertEqual(
23 scanstring('["Unclosed array"', 2, True),
24 ('Unclosed array', 17))
25
26 self.assertEqual(
27 scanstring('["extra comma",]', 2, True),
28 ('extra comma', 14))
29
30 self.assertEqual(
31 scanstring('["double extra comma",,]', 2, True),
32 ('double extra comma', 21))
33
34 self.assertEqual(
35 scanstring('["Comma after the close"],', 2, True),
36 ('Comma after the close', 24))
37
38 self.assertEqual(
39 scanstring('["Extra close"]]', 2, True),
40 ('Extra close', 14))
41
42 self.assertEqual(
43 scanstring('{"Extra comma": true,}', 2, True),
44 ('Extra comma', 14))
45
46 self.assertEqual(
47 scanstring('{"Extra value after close": true} "misplaced quoted value"', 2, True),
48 ('Extra value after close', 26))
49
50 self.assertEqual(
51 scanstring('{"Illegal expression": 1 + 2}', 2, True),
52 ('Illegal expression', 21))
53
54 self.assertEqual(
55 scanstring('{"Illegal invocation": alert()}', 2, True),
56 ('Illegal invocation', 21))
57
58 self.assertEqual(
59 scanstring('{"Numbers cannot have leading zeroes": 013}', 2, True),
60 ('Numbers cannot have leading zeroes', 37))
61
62 self.assertEqual(
63 scanstring('{"Numbers cannot be hex": 0x14}', 2, True),
64 ('Numbers cannot be hex', 24))
65

Callers

nothing calls this directly

Calls 2

scanstringFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected