def test_has_command_custom_commands(state): with setup_workspace(): update_bash_history_info() has_command(state, "(a|b)+", "a and b are the best letters", commands=["old command"])
def test_prepare_validation(state): state.force_diagnose = True with setup_workspace(): update_bash_history_info() prepare_validation(state, ["ls", "echo abc"]) has_command(state, "ls", "good job") has_command(state, "echo.*c", "well done")
def test_has_command_fixed(state): with setup_workspace() as (bash_history_path, bash_history_info_path): update_bash_history_info() Path(bash_history_path.name).write_text("(a|b)+") has_command(state, "(a|b)+", "a and b are the best letters", fixed=True)
def test_has_command_failure(state): with setup_workspace() as (bash_history_path, bash_history_info_path): update_bash_history_info() Path(bash_history_path.name).write_text("wrong") with pytest.raises(TF, match="a and b"): has_command(state, "(a|b)+", "a and b are the best letters")
def test_has_command_no_commands(state): with setup_workspace(): update_bash_history_info() with pytest.raises(TF, match="didn't find any"): has_command(state, "(a|b)+", "a and b are the best letters")