def test_expected_arg_attrs(): """With an empty list we should always get args with the specified attributes.""" args = cli.cli_args([]) expected_args = [ "exclude", "mode", "nlocations", "output", "rseed", "src", "testcmds", "debug", "nocov", ] for e in expected_args: assert hasattr(args, e)
def test_search_file_order_bad_key_mutatest_ini(tmp_path, section, monkeypatch): """Ensuring the search hierarchy works, if the mutatest.ini is configured without the required [mutatest] key, the setup.cfg is searched next for each key type. """ f1 = "[mypy]\nmval=123" f2 = f"[isort]\nival=456\n\n[{section}]\nmode=sd" write_order = ["mutatest.ini", "setup.cfg"] for fp, contents in zip(write_order, [f1, f2]): with open(tmp_path / fp, "w") as fstream: fstream.write(contents) monkeypatch.chdir(tmp_path) result = cli.cli_args([]) assert result.mode == "sd"
def test_read_setup_cfg_missing_mutatest_ini(tmp_path, section, monkeypatch): """Setup.cfg will support both [mutatest] and [tool:mutatest] sections.""" ini_contents = dedent(f"""\ [{section}] whitelist = nc su ix""") expected = ["nc", "su", "ix"] with open(tmp_path / "setup.cfg", "w") as fstream: fstream.write(ini_contents) monkeypatch.chdir(tmp_path) result = cli.cli_args([]) print(result.__dict__) assert len(result.whitelist) == 3 for r, e in zip(result.whitelist, expected): assert r == e
def test_syserror_negative_n_and_rseed(n, i): """Property: 1. Given a negative n-value a SystemExit is raised. """ with pytest.raises(SystemExit): _ = cli.cli_args([n, f"{i}"])