|
@@ 607-618 (lines=12) @@
|
| 604 |
|
dic = copy.deepcopy(self.dic) |
| 605 |
|
self.assert_dicts_equal(res, dic) |
| 606 |
|
|
| 607 |
|
res = TT.load(self.g_path, parse_int=int) |
| 608 |
|
exp = copy.deepcopy(self.exp) |
| 609 |
|
self.assert_dicts_equal(res, exp) |
| 610 |
|
|
| 611 |
|
res = TT.load([self.a_path, self.b_path], parse_int=int) |
| 612 |
|
exp = copy.deepcopy(self.exp) |
| 613 |
|
self.assert_dicts_equal(res, exp) |
| 614 |
|
|
| 615 |
|
def test_34_load__ignore_missing(self): |
| 616 |
|
cpath = os.path.join(os.curdir, "conf_file_should_not_exist") |
| 617 |
|
assert not os.path.exists(cpath) |
| 618 |
|
|
| 619 |
|
self.assertEqual(TT.load([cpath], ac_parser="ini", |
| 620 |
|
ignore_missing=True), |
| 621 |
|
NULL_CNTNR) |
|
@@ 594-605 (lines=12) @@
|
| 591 |
|
|
| 592 |
|
with TT.open(self.a_path) as strm: |
| 593 |
|
res = TT.load(strm, ac_parser="json") |
| 594 |
|
self.assert_dicts_equal(res, self.dic) |
| 595 |
|
|
| 596 |
|
def test_32_dump_and_load__w_options(self): |
| 597 |
|
TT.dump(self.dic, self.a_path, indent=2) |
| 598 |
|
self.assertTrue(os.path.exists(self.a_path)) |
| 599 |
|
|
| 600 |
|
TT.dump(self.upd, self.b_path, indent=2) |
| 601 |
|
self.assertTrue(os.path.exists(self.b_path)) |
| 602 |
|
|
| 603 |
|
res = TT.load(self.a_path, parse_int=int) |
| 604 |
|
dic = copy.deepcopy(self.dic) |
| 605 |
|
self.assert_dicts_equal(res, dic) |
| 606 |
|
|
| 607 |
|
res = TT.load(self.g_path, parse_int=int) |
| 608 |
|
exp = copy.deepcopy(self.exp) |
|
@@ 360-371 (lines=12) @@
|
| 357 |
|
self.assertEqual(out.mode, wmode) |
| 358 |
|
|
| 359 |
|
with TT.open(cpath, 'rb', **oopts) as inp: |
| 360 |
|
cnf1 = TT.single_load(inp) |
| 361 |
|
self.assertTrue(_is_file_object(inp)) |
| 362 |
|
self.assertEqual(inp.mode, rmode) |
| 363 |
|
cpair = (self.cnf, cnf1) |
| 364 |
|
self.assertTrue(dicts_equal(*cpair), "%r vs. %r" % cpair) |
| 365 |
|
|
| 366 |
|
def test_10_open_json_file(self): |
| 367 |
|
self._load_and_dump_with_opened_files("a.json") |
| 368 |
|
|
| 369 |
|
def test_20_open_xml_file(self): |
| 370 |
|
if "xml" in anyconfig.backends.list_types(): |
| 371 |
|
self._load_and_dump_with_opened_files("a.xml", 'rb', 'wb') |
| 372 |
|
|
| 373 |
|
def test_30_open_bson_file(self): |
| 374 |
|
if "bson" in anyconfig.backends.list_types(): |
|
@@ 167-176 (lines=10) @@
|
| 164 |
|
|
| 165 |
|
self.assertEqual(a1["requires"], a["requires"]) |
| 166 |
|
|
| 167 |
|
def test_48_loads_w_validation(self): |
| 168 |
|
cnf_s = TT.dumps(CNF_0, "json") |
| 169 |
|
scm_s = TT.dumps(SCM_0, "json") |
| 170 |
|
cnf_2 = TT.loads(cnf_s, ac_parser="json", ac_context={}, |
| 171 |
|
ac_schema=scm_s) |
| 172 |
|
|
| 173 |
|
self.assertEqual(cnf_2["name"], CNF_0["name"]) |
| 174 |
|
self.assertEqual(cnf_2["a"], CNF_0["a"]) |
| 175 |
|
self.assertEqual(cnf_2["b"]["b"], CNF_0["b"]["b"]) |
| 176 |
|
self.assertEqual(cnf_2["b"]["c"], CNF_0["b"]["c"]) |
| 177 |
|
|
| 178 |
|
def test_49_loads_w_validation_error(self): |
| 179 |
|
cnf_s = """{"a": "aaa"}""" |