def test_48_loads_w_validation(self): cnf_s = TT.dumps(CNF_0, "json") scm_s = TT.dumps(SCM_0, "json") cnf_2 = TT.loads(cnf_s, ac_parser="json", ac_context={}, ac_schema=scm_s) self.assertEqual(cnf_2["name"], CNF_0["name"]) self.assertEqual(cnf_2["a"], CNF_0["a"]) self.assertEqual(cnf_2["b"]["b"], CNF_0["b"]["b"]) self.assertEqual(cnf_2["b"]["c"], CNF_0["b"]["c"])
def test_30_dumps_and_loads(self): a = dict(name="a", a=1, b=dict(b=[1, 2], c="C")) a1 = A.loads(A.dumps(a, "json"), "json") self.assertEquals(a1["name"], a["name"]) self.assertEquals(a1["a"], a["a"]) self.assertEquals(a1["b"]["b"], a["b"]["b"]) self.assertEquals(a1["b"]["c"], a["b"]["c"])
def test_30_dumps_and_loads__w_options(self): a = dict(name="a", a=1, b=dict(b=[1, 2], c="C")) a1 = A.loads(A.dumps(a, "json", indent=2), "json", ensure_ascii=False) self.assertEquals(a1["name"], a["name"]) self.assertEquals(a1["a"], a["a"]) self.assertEquals(a1["b"]["b"], a["b"]["b"]) self.assertEquals(a1["b"]["c"], a["b"]["c"])
def test_32_dumps_and_loads__w_options__no_dumper(self): a = dict(name="a", a=1, b=dict(b=[1, 2], c="C")) a1 = A.loads(A.dumps(a, "type_not_exist"), "json") self.assertEquals(a1["name"], a["name"]) self.assertEquals(a1["a"], a["a"]) self.assertEquals(a1["b"]["b"], a["b"]["b"]) self.assertEquals(a1["b"]["c"], a["b"]["c"])
def test_49_loads_w_validation_error(self): if not anyconfig.schema.JSONSCHEMA_IS_AVAIL: skip_test() cnf_s = """{"a": "aaa"}""" scm_s = TT.dumps(SCM_0, "json") cnf_2 = TT.loads(cnf_s, ac_parser="json", ac_schema=scm_s) self.assertTrue(cnf_2 is None, cnf_2)
def test_30_dumps_and_loads(self): res = TT.loads(TT.dumps(self.cnf, "json"), "json") self.assert_dicts_equal(res, self.cnf)
def test_49_loads_w_validation_error(self): cnf_s = """{"a": "aaa"}""" scm_s = TT.dumps(SCM_0, "json") cnf_2 = TT.loads(cnf_s, ac_parser="json", ac_schema=scm_s) self.assertTrue(cnf_2 is None, cnf_2)
def test_32_dumps_and_loads__w_options__no_dumper(self): cnf = TT.loads(TT.dumps(self.cnf, "type_not_exist"), "json") self.assertTrue(dicts_equal(cnf, self.cnf), str(cnf))
def test_30_dumps_and_loads__w_options(self): cnf = TT.loads(TT.dumps(self.cnf, "json", indent=2), "json", ensure_ascii=False) self.assertTrue(dicts_equal(cnf, self.cnf), str(cnf))
def test_30_dumps_and_loads__w_options(self): res = TT.loads(TT.dumps(self.cnf, "json", indent=2), "json", ensure_ascii=False) self.assert_dicts_equal(res, self.cnf)
def test_30_dumps_and_loads(self): cnf = TT.loads(TT.dumps(self.cnf, "json"), "json") self.assertTrue(dicts_equal(cnf, self.cnf), str(cnf))