|
@@ 600-611 (lines=12) @@
|
| 597 |
|
b = dict(a=2, b=dict(b=[1, 2, 3, 4, 5], d="D")) |
| 598 |
|
|
| 599 |
|
a_path = os.path.join(self.workdir, "a.json") |
| 600 |
|
b_path = os.path.join(self.workdir, "b.json") |
| 601 |
|
|
| 602 |
|
TT.dump(a, a_path, indent=2) |
| 603 |
|
self.assertTrue(os.path.exists(a_path)) |
| 604 |
|
|
| 605 |
|
TT.dump(b, b_path, indent=2) |
| 606 |
|
self.assertTrue(os.path.exists(b_path)) |
| 607 |
|
|
| 608 |
|
a1 = TT.load(a_path, parse_int=int) |
| 609 |
|
|
| 610 |
|
self.assertEqual(a1["name"], a["name"]) |
| 611 |
|
self.assertEqual(a1["a"], a["a"]) |
| 612 |
|
self.assertEqual(a1["b"]["b"], a["b"]["b"]) |
| 613 |
|
self.assertEqual(a1["b"]["c"], a["b"]["c"]) |
| 614 |
|
|
|
@@ 587-598 (lines=12) @@
|
| 584 |
|
with open(cpath, 'w') as strm: |
| 585 |
|
TT.dump(cnf, strm) |
| 586 |
|
|
| 587 |
|
self.assertTrue(os.path.exists(cpath)) |
| 588 |
|
|
| 589 |
|
with open(cpath, 'r') as strm: |
| 590 |
|
cnf1 = TT.load(strm, ac_parser="json") |
| 591 |
|
|
| 592 |
|
self.assertTrue(dicts_equal(cnf, cnf1), |
| 593 |
|
"cnf vs. cnf1: %s\n\n%s" % (str(cnf), str(cnf1))) |
| 594 |
|
|
| 595 |
|
def test_32_dump_and_load__w_options(self): |
| 596 |
|
a = dict(a=1, b=dict(b=[0, 1], c="C"), name="a") |
| 597 |
|
b = dict(a=2, b=dict(b=[1, 2, 3, 4, 5], d="D")) |
| 598 |
|
|
| 599 |
|
a_path = os.path.join(self.workdir, "a.json") |
| 600 |
|
b_path = os.path.join(self.workdir, "b.json") |
| 601 |
|
|
|
@@ 140-149 (lines=10) @@
|
| 137 |
|
|
| 138 |
|
a1 = TT.loads(a_s, ac_parser="yaml", ac_template=True, |
| 139 |
|
ac_context=context) |
| 140 |
|
|
| 141 |
|
a = dict(requires=["bash", "zsh"]) |
| 142 |
|
self.assertEqual(a1["requires"], a["requires"]) |
| 143 |
|
|
| 144 |
|
def test_46_loads_w_type__broken_template(self): |
| 145 |
|
if not anyconfig.template.SUPPORTED: |
| 146 |
|
return |
| 147 |
|
|
| 148 |
|
a = dict(requires="{% }}", ) |
| 149 |
|
a_s = 'requires: "{% }}"' |
| 150 |
|
a1 = TT.loads(a_s, ac_parser="yaml", ac_template=True, |
| 151 |
|
ac_context={}) |
| 152 |
|
|