Code Duplication    Length = 10-12 lines in 4 locations

tests/api.py 4 locations

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