def test_from_file(): with tempfile.NamedTemporaryFile() as fp: s = b'a: b' fp.write(s) fp.flush() fp.seek(0) c = OmegaConf.from_file(fp.file) assert {'a': 'b'} == c
def save_load__from_file(conf): try: with tempfile.NamedTemporaryFile(mode="wt", delete=False) as fp: conf.save(fp.file) with io.open(os.path.abspath(fp.name), 'rt') as handle: c2 = OmegaConf.from_file(handle) assert conf == c2 finally: os.unlink(fp.name)