MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / test_json

Method test_json

functional/test/test_streams.py:143–162  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

141 self.assertEqual(expect_0, result_0)
142
143 def test_json(self):
144 list_test_path = "functional/test/data/test_list.json"
145 dict_test_path = "functional/test/data/test_dict.json"
146 list_expect = [1, 2, 3, 4, 5]
147 dict_expect = list({u"a": 1, u"b": 2, u"c": 3}.items())
148
149 result = self.seq.json(list_test_path).to_list()
150 self.assertEqual(list_expect, result)
151 result = self.seq.json(dict_test_path).to_list()
152 self.assertEqual(dict_expect, result)
153
154 with open(list_test_path) as file_handle:
155 result = self.seq.json(file_handle).to_list()
156 self.assertEqual(list_expect, result)
157 with open(dict_test_path) as file_handle:
158 result = self.seq.json(file_handle).to_list()
159 self.assertEqual(dict_expect, result)
160
161 with self.assertRaises(ValueError):
162 self.seq.json(1)
163
164 def test_gzip_json(self):
165 list_test_path = "functional/test/data/test_list.json.gz"

Callers

nothing calls this directly

Calls 2

to_listMethod · 0.80
jsonMethod · 0.80

Tested by

no test coverage detected