def test_load_referenced_serialized_top(self): with open(f"{self.out_dir}/tmp1.yaml", "w") as f_out: yaml.dump(DummyClass(arg1="v1"), f_out) test_obj = yaml.load(f"!LoadSerialized {{ filename: {self.out_dir}/tmp1.yaml }}") loaded_obj = YamlPreloader._load_serialized(test_obj) self.assertIsInstance(loaded_obj, DummyClass) self.assertEqual(loaded_obj.arg1, "v1")
def test_load_referenced_serialized_nested(self): with open(f"{self.out_dir}/tmp1.yaml", "w") as f_out: yaml.dump(DummyClass(arg1="v1"), f_out) test_obj = yaml.load(f""" a: 1 b: !LoadSerialized filename: {self.out_dir}/tmp1.yaml overwrite: - path: arg1 val: !LoadSerialized filename: {self.out_dir}/tmp1.yaml """) loaded_obj = YamlPreloader._load_serialized(test_obj) self.assertIsInstance(loaded_obj["b"], DummyClass) self.assertIsInstance(loaded_obj["b"].arg1, DummyClass)