def test__main_base(standard_out: Any, standard_error: Any) -> None: fname = "tests/good/tests_changeable_string_BASE.py" write_changeable_string(fname) # Hard check: need changes Exit args = ["--check-hard", f"--files={fname}"] with pytest.raises(SystemExit) as pytest_wrapped_e: res = _main(args=args, standard_out=standard_out, standard_error=standard_error) assert pytest_wrapped_e.type == SystemExit errcode = f"Error: --check-hard: need changes in file: {fname}" assert pytest_wrapped_e.value.code == errcode # Soft check: no need changes args = [ "--diff", "--diff-to-txt", "--new-file", "--in-place", "--check-soft", f"--files={fname}" ] res = _main(args=args, standard_out=standard_out, standard_error=standard_error) # Hard check: no need changes args = ["--check-hard", f"--files={fname}"] res = _main(args=args, standard_out=standard_out, standard_error=standard_error) remove_file(fname)
def test__main_exit_recursive(standard_out: Any, standard_error: Any) -> None: fname = "tests/good/" args = ["--check-soft", "--recursive", f"--files={fname}"] res = _main(args=args, standard_out=standard_out, standard_error=standard_error) remove_file(fname)
def test__main_no_file(standard_out: Any, standard_error: Any) -> None: fname = "tests/good/tests_changeable_string_EXIT.py" remove_file(fname) args = [f"--files={fname}"] with pytest.raises(IOError) as pytest_wrapped_e: res = _main(args=args, standard_out=standard_out, standard_error=standard_error) errcode = (2, f"File is not exist: {fname}") assert pytest_wrapped_e.value.args == errcode
def test__show_args(standard_out: Any, standard_error: Any) -> None: fname = "tests/good/tests_changeable_string_EXIT.py" write_changeable_string(fname) args = ["--show-args", f"--files={fname}"] with pytest.raises(SystemExit) as pytest_wrapped_e: res = _main(args=args, standard_out=standard_out, standard_error=standard_error) assert pytest_wrapped_e.type == SystemExit errcode = 0 assert pytest_wrapped_e.value.code == 0 remove_file(fname)
def test__main_exit_check_hard(standard_out: Any, standard_error: Any) -> None: fname = "tests/good/tests_changeable_string_EXIT.py" write_changeable_string(fname) args = ["--check-hard", f"--files={fname}"] with pytest.raises(SystemExit) as pytest_wrapped_e: res = _main(args=args, standard_out=standard_out, standard_error=standard_error) assert pytest_wrapped_e.type == SystemExit errcode = f"Error: --check-hard: need changes in file: {fname}" assert pytest_wrapped_e.value.code == errcode remove_file(fname)
def test__remaining_argv(standard_out: Any, standard_error: Any) -> None: fname = "tests/good/tests_changeable_string_EXIT.py" write_changeable_string(fname) args = [] args.append("--HAHAHAH_remaining_argv_AHAHAHA") args.append(f"--files={fname}") with pytest.raises(IOError) as pytest_wrapped_e: res = _main(args=args, standard_out=standard_out, standard_error=standard_error) errcode = (2, f"File is not exist: --HAHAHAH_remaining_argv_AHAHAHA") assert pytest_wrapped_e.value.args == errcode remove_file(fname)
def test__main(standard_out: Any, standard_error: Any) -> None: fname = "tests/good/tests_changeable_string_MAIN.py" write_changeable_string(fname) args = [] args.append("--save-values-to-file") args.append("--debug") args.append("--diff") args.append("--diff-to-txt") args.append("--new-file") args.append("--in-place") args.append("--check") args.append("--recursive") args.append("--print-files") args.append(f"--files={fname}") res = _main(args=args, standard_out=standard_out, standard_error=standard_error) remove_file(fname)