-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_issue7.py
More file actions
55 lines (45 loc) · 1.22 KB
/
Copy pathtest_issue7.py
File metadata and controls
55 lines (45 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import json
import unittest
from jsonasobj import JsonObj, loads, as_json, as_json_obj, as_dict
s_list = '''[
{
"a": 17,
"b": "sell",
"c": [
1,
2,
3
],
"d": null,
"e": {},
"f": {
"g": -12.56
}
},
143
]'''
p_list = [{'a': 17, 'b': 'sell', 'c': [1, 2, 3], 'd': None, 'e': {}, 'f': {'g': -12.56}}, 143]
class OuterListTestCase(unittest.TestCase):
""" Test various forms of outermost lists """
def test_loads_list(self):
t1 = loads(s_list)
self.assertEqual(p_list, as_json_obj(t1))
self.assertEqual(s_list, as_json(t1))
def test_list_constructor(self):
t1 = loads(s_list)
t1_dict = as_json_obj(t1)
self.assertEqual(p_list, t1_dict)
t2 = JsonObj(t1_dict)
self.assertEqual(s_list, as_json(t2))
def test_list_subscripts(self):
t1 = loads(s_list)
self.assertEqual(3, t1[0].c[2])
self.assertEqual(-12.56, t1[0].f.g)
@unittest.skip("Setters have yet to be implemented")
def test_list_setters(self):
t1 = JsonObj([])
print(t1)
t1.append('14')
print(as_json(t1))
if __name__ == '__main__':
unittest.main()