def test_env_singleton(cwas_env_path: Path): env1 = Env() env2 = Env() assert env1 is env2 new_env_path = Path(str(cwas_env_path) + "_new") env3 = Env(new_env_path) env4 = Env() assert env1 is env3 assert env1 is env4 assert env1.get_path() is new_env_path env1.set_path(cwas_env_path)
def __init__(self, args: argparse.Namespace): self.env = Env() arg_dict = vars(args) for arg in arg_dict: arg_val = arg_dict.get(arg) if isinstance(arg_val, Path): arg_val = arg_val.resolve() setattr(self, arg, arg_val)
def teardown(cwas_workspace): yield env = Env() env.reset() env.remove_file() for f in cwas_workspace.glob("*"): f.unlink() cwas_workspace.rmdir()
def set_env(cwas_workspace, annotation_dir): env = Env() env.set_env("CWAS_WORKSPACE", cwas_workspace) env.set_env("VEP", "VEP") env.set_env("ANNOTATION_DATA", annotation_dir) env.set_env("ANNOTATION_BW_KEY", annotation_dir / "bw_key.yaml") env.set_env("MERGED_BED", cwas_workspace / "merged.bed.gz") env.set_env("MERGED_BED_INDEX", cwas_workspace / "merged.bed.gz.tbi") env.save()
def teardown(cwas_workspace: Path, vep_mock: Path): yield vep_mock.unlink() env = Env() env.reset() env.remove_file() for f in cwas_workspace.glob("*"): f.unlink() cwas_workspace.rmdir()
def cwas_env_inst(cwas_env_path): env_inst = Env(cwas_env_path) yield env_inst.remove_file()
def env_inst(): return Env()
def reset_env(): env = Env() env.reset() env.remove_file()
def set_env(cwas_workspace: Path, annotation_dir: Path): env = Env() env.set_env("CWAS_WORKSPACE", cwas_workspace) env.set_env("ANNOTATION_DATA", annotation_dir) env.set_env("ANNOTATION_BED_KEY", cwas_workspace / "bed_key.yaml") env.save()
def test_run_without_configuration(): inst = PreparationMock.get_instance() Env().reset() with pytest.raises(RuntimeError): inst.run()
def set_env(cwas_workspace: Path): env = Env() env.set_env("CWAS_WORKSPACE", cwas_workspace) env.save()
def _make_env_empty(): env = Env() env.reset() env.save()