def test_num(parser: exman.ExParser): assert parser.num_ex() == 0 assert parser.next_ex() == 1 parser.parse_args([]) assert parser.num_ex() == 1 assert parser.next_ex() == 2 parser.parse_args(["--tmp"]) assert parser.num_ex() == 1 assert parser.next_ex() == 3
def test_named_dirs(parser: exman.ExParser): args = parser.parse_args(["--name", "foo"]) assert args.root.exists() assert args.root.name.startswith("1".zfill(parser.zfill) + "-") assert args.root.name.endswith("foo") args = parser.parse_args(["--name", "bar"]) assert args.root.exists() assert args.root.name.startswith("2".zfill(parser.zfill) + "-") assert args.root.name.endswith("bar")
def test_list_in_yaml(parser: exman.ExParser): parser.add_argument("--list", nargs=2, type=int, default=[1, 3]) parser.parse_args([]) namespace = parser.parse_args("--list 1 4".split()) assert isinstance(namespace.list, list) info = exman.Index(parser.root).info() assert isinstance(info.list[0], list) assert isinstance(info.list[0][0], int) assert isinstance(info.list[1], list) assert isinstance(info.list[1][0], int)
def test_collect(parser: exman.ExParser): args = parser.parse_args("--arg1=10 --arg2=F".split()) parser.parse_args("--arg1=9 --arg2=t".split()) info = exman.Index(parser.root).info() assert len(info) == 2 assert str(info.dtypes.arg2) == "bool" assert str(info.dtypes.arg1) == "int64" assert isinstance(info.root[0], pathlib.Path) assert info.root[0] == args.root assert str(info.dtypes.time) == "datetime64[ns]"
def test_marked(parser: exman.ExParser, script_runner, root, mark): parser.parse_args("--arg1=10 --arg2=F".split()) parser.parse_args("--arg1=9 --arg2=t".split()) run_info = script_runner.run("exman", "mark", mark, "1", cwd=root) assert run_info.success info = exman.Index(parser.root).info() new = exman.Index(parser.root).info(mark) assert len(info) == 2 assert len(new) == 1 assert new.id[0] == 1 with pytest.raises(KeyError): exman.Index(parser.root).info("missing")
def test_mark(parser: exman.ExParser, script_runner, root, mark): script_runner.launch_mode = "in_process" args = parser.parse_args([]) info = script_runner.run("exman", "mark", mark, "1", "2", cwd=root) assert info.success assert (parser.marked / mark / args.root.name).exists() assert r"runs {2} were not found" in info.stderr
def test_dirs(parser: exman.ExParser): args = parser.parse_args([]) assert args.root.exists() assert args.root.name.startswith("1".zfill(parser.zfill) + "-") assert parser.runs.exists() assert parser.index.exists() assert (parser.index / exman.parser.yaml_file(args.root.name)).exists()
def test_delete_all(parser: exman.ExParser, script_runner, root): script_runner.launch_mode = "in_process" args = parser.parse_args([]) assert (parser.runs / args.root.name).exists() assert (parser.index / exman.parser.yaml_file(args.root.name)).exists() info1 = script_runner.run("exman", "delete", "--all", "1", "2", cwd=root) assert info1.success assert r"runs {2} were not found" in info1.stderr assert not (parser.index / exman.parser.yaml_file(args.root.name)).exists() assert not (parser.runs / args.root.name).exists()