Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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"))
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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"
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
def test_init_from_file() -> None:
    """__init__() works correctly from string."""
    true = pwhich("true")
    zoon = Zoon(true)
    assert "%r" % zoon == f"zoon.Zoon('{true}')"
Ejemplo n.º 9
0
def test_pwhich() -> None:
    """Executing pwhich() succeeds."""
    truepath = pwhich("true")
    assert subprocess.run(str(truepath), check=True).returncode == 0  # nosec
Ejemplo n.º 10
0
def test_run_test_true() -> None:
    """Simple success."""
    expected = (0, "success", "", "")
    assert run(str(pwhich("true"))) == expected