| @@ 43-67 (lines=25) @@ | ||
| 40 | empty_patterns = ['', '{}', '[]', 'null'] |
|
| 41 | ||
| 42 | ||
| 43 | class Test_20(TBC.Test_20_dump_and_load, HasParserTrait): |
|
| 44 | ||
| 45 | def test_18_load__list(self): |
|
| 46 | if self.is_ready(): |
|
| 47 | # overwrite it. |
|
| 48 | with self.psr.wopen(self.cnf_path) as out: |
|
| 49 | out.write("[1, 2]\n") |
|
| 50 | ||
| 51 | ioi = self._to_ioinfo(self.cnf_path) |
|
| 52 | ||
| 53 | cnf = self.psr.load(ioi) |
|
| 54 | self.assertTrue(cnf) |
|
| 55 | self.assertEqual(cnf, [1, 2]) |
|
| 56 | ||
| 57 | def test_18_load__list_1(self): |
|
| 58 | if self.is_ready(): |
|
| 59 | # overwrite it. |
|
| 60 | with self.psr.wopen(self.cnf_path) as out: |
|
| 61 | out.write('[{"a": 1}, {"a": 2}]\n') |
|
| 62 | ||
| 63 | ioi = self._to_ioinfo(self.cnf_path) |
|
| 64 | ||
| 65 | cnf = self.psr.load(ioi) |
|
| 66 | self.assertTrue(cnf) |
|
| 67 | self.assertEqual(cnf, [{"a": 1}, {"a": 2}]) |
|
| 68 | ||
| 69 | # vim:sw=4:ts=4:et: |
|
| 70 | ||
| @@ 52-75 (lines=24) @@ | ||
| 49 | empty_patterns = ['', ' ', "#%s#%s" % (os.linesep, os.linesep)] |
|
| 50 | ||
| 51 | ||
| 52 | class Test_20(TBC.Test_20_dump_and_load, HasParserTrait): |
|
| 53 | ||
| 54 | def test_18_load__list(self): |
|
| 55 | if self.is_ready(): |
|
| 56 | # overwrite it. |
|
| 57 | with self.psr.wopen(self.cnf_path) as out: |
|
| 58 | out.write("- 1\n- 2\n") |
|
| 59 | ||
| 60 | ioi = self._to_ioinfo(self.cnf_path) |
|
| 61 | ||
| 62 | cnf = self.psr.load(ioi) |
|
| 63 | self.assertTrue(cnf) |
|
| 64 | self.assertEqual(cnf, [1, 2]) |
|
| 65 | ||
| 66 | def test_19_load__nested_list(self): |
|
| 67 | if self.is_ready(): |
|
| 68 | with self.psr.wopen(self.cnf_path) as out: |
|
| 69 | out.write('[{"a": 1}, {"a": 2}]\n') |
|
| 70 | ||
| 71 | ioi = self._to_ioinfo(self.cnf_path) |
|
| 72 | ||
| 73 | cnf = self.psr.load(ioi) |
|
| 74 | self.assertTrue(cnf) |
|
| 75 | self.assertEqual(cnf, [{"a": 1}, {"a": 2}]) |
|
| 76 | ||
| 77 | # vim:sw=4:ts=4:et: |
|
| 78 | ||