]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.10/Lib/json/tests/test_fail.py
1 from json
.tests
import PyTest
, CTest
5 # http://json.org/JSON_checker/test/fail1.json
6 '"A JSON payload should be an object or array, not a string."',
7 # http://json.org/JSON_checker/test/fail2.json
9 # http://json.org/JSON_checker/test/fail3.json
10 '{unquoted_key: "keys must be quoted"}',
11 # http://json.org/JSON_checker/test/fail4.json
13 # http://json.org/JSON_checker/test/fail5.json
14 '["double extra comma",,]',
15 # http://json.org/JSON_checker/test/fail6.json
16 '[ , "<-- missing value"]',
17 # http://json.org/JSON_checker/test/fail7.json
18 '["Comma after the close"],',
19 # http://json.org/JSON_checker/test/fail8.json
21 # http://json.org/JSON_checker/test/fail9.json
22 '{"Extra comma": true,}',
23 # http://json.org/JSON_checker/test/fail10.json
24 '{"Extra value after close": true} "misplaced quoted value"',
25 # http://json.org/JSON_checker/test/fail11.json
26 '{"Illegal expression": 1 + 2}',
27 # http://json.org/JSON_checker/test/fail12.json
28 '{"Illegal invocation": alert()}',
29 # http://json.org/JSON_checker/test/fail13.json
30 '{"Numbers cannot have leading zeroes": 013}',
31 # http://json.org/JSON_checker/test/fail14.json
32 '{"Numbers cannot be hex": 0x14}',
33 # http://json.org/JSON_checker/test/fail15.json
34 '["Illegal backslash escape: \\x15"]',
35 # http://json.org/JSON_checker/test/fail16.json
37 # http://json.org/JSON_checker/test/fail17.json
38 '["Illegal backslash escape: \\017"]',
39 # http://json.org/JSON_checker/test/fail18.json
40 '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]',
41 # http://json.org/JSON_checker/test/fail19.json
42 '{"Missing colon" null}',
43 # http://json.org/JSON_checker/test/fail20.json
44 '{"Double colon":: null}',
45 # http://json.org/JSON_checker/test/fail21.json
46 '{"Comma instead of colon", null}',
47 # http://json.org/JSON_checker/test/fail22.json
48 '["Colon instead of comma": false]',
49 # http://json.org/JSON_checker/test/fail23.json
50 '["Bad value", truth]',
51 # http://json.org/JSON_checker/test/fail24.json
53 # http://json.org/JSON_checker/test/fail25.json
54 '["\ttab\tcharacter\tin\tstring\t"]',
55 # http://json.org/JSON_checker/test/fail26.json
56 '["tab\\ character\\ in\\ string\\ "]',
57 # http://json.org/JSON_checker/test/fail27.json
59 # http://json.org/JSON_checker/test/fail28.json
61 # http://json.org/JSON_checker/test/fail29.json
63 # http://json.org/JSON_checker/test/fail30.json
65 # http://json.org/JSON_checker/test/fail31.json
67 # http://json.org/JSON_checker/test/fail32.json
68 '{"Comma instead if closing brace": true,',
69 # http://json.org/JSON_checker/test/fail33.json
71 # http://code.google.com/p/simplejson/issues/detail?id=3
72 u
'["A\u001FZ control characters in string"]',
76 1: "why not have a string payload?",
77 18: "spec doesn't specify any nesting limitations",
80 class TestFail(object):
81 def test_failures(self
):
82 for idx
, doc
in enumerate(JSONDOCS
):
92 self
.fail("Expected failure for fail{0}.json: {1!r}".format(idx
, doc
))
94 def test_non_string_keys_dict(self
):
95 data
= {'a' : 1, (1, 2) : 2}
97 #This is for c encoder
98 self
.assertRaises(TypeError, self
.dumps
, data
)
100 #This is for python encoder
101 self
.assertRaises(TypeError, self
.dumps
, data
, indent
=True)
104 class TestPyFail(TestFail
, PyTest
): pass
105 class TestCFail(TestFail
, CTest
): pass