def test_run_test_false() -> None: """Simple failure.""" false = str(pwhich("false")) expected = ( 1, "calledprocesserror", "", f"Command '['{false}']' returned non-zero exit status 1.", ) assert run(str(pwhich("false"))) == expected
def test_defaults() -> None: """ParamParser defaults.""" params = parse_params() assert params.loglevel == logging.ERROR assert params.wild_type == pwhich("true") assert not params.mutants assert not params.cmd_args assert not params.bit_range assert not params.bit_file
def config_parser(configfiles): """Parse a configfile and return a named tuple of its contents.""" # TODO: handle bits, cmd_args, mutants config = configparser.ConfigParser() config.read(configfiles) wild_type = config.get("core", "wild_type", fallback=pwhich("true")) Configs = collections.namedtuple("Configs", "wild_type") configs = Configs(wild_type=wild_type) return configs
def test_write_bad_dir() -> None: """Write to a non-existent path.""" true = pwhich("true") zoon = Zoon(true) with pytest.raises(FileNotFoundError): zoon.write(Path("/u/jane/me/tarzan"))
def test_file_len() -> None: """len() works correctly on Zoon from file.""" true = pwhich("true") zoon = Zoon(true) assert len(zoon) == Path(true).stat().st_size * 8
def test_mutate_and_run(tmpdir) -> None: """mutate_and_run does that.""" zoon = Zoon(pwhich("true")) result = zoon.mutate_and_run(0, Path(tmpdir), "--help", 1) assert result[1] != "success"
def test_run(tmp_path) -> None: """Run a zoon.""" expected = (0, "success", "", "") true = pwhich("true") zoon = Zoon(true) assert zoon.run(tmp_path / "true") == expected
def test_init_from_file() -> None: """__init__() works correctly from string.""" true = pwhich("true") zoon = Zoon(true) assert "%r" % zoon == f"zoon.Zoon('{true}')"
def test_pwhich() -> None: """Executing pwhich() succeeds.""" truepath = pwhich("true") assert subprocess.run(str(truepath), check=True).returncode == 0 # nosec
def test_run_test_true() -> None: """Simple success.""" expected = (0, "success", "", "") assert run(str(pwhich("true"))) == expected