mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 12:06:04 +00:00
2a166a7dec
Co-authored-by: user <avi.salmon@intel.com> Co-authored-by: Pablo Santiago Blum de Aguiar <scorphus@gmail.com>
31 lines
890 B
Python
31 lines
890 B
Python
import pytest
|
|
|
|
from thefuck.rules.wrong_hyphen_before_subcommand import match, get_new_command
|
|
from thefuck.types import Command
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def get_all_executables(mocker):
|
|
mocker.patch(
|
|
"thefuck.rules.wrong_hyphen_before_subcommand.get_all_executables",
|
|
return_value=["git", "apt", "apt-get", "ls", "pwd"],
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("script", ["git-log", "apt-install python"])
|
|
def test_match(script):
|
|
assert match(Command(script, ""))
|
|
|
|
|
|
@pytest.mark.parametrize("script", ["ls -la", "git2-make", "apt-get install python"])
|
|
def test_not_match(script):
|
|
assert not match(Command(script, ""))
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"script, new_command",
|
|
[("git-log", "git log"), ("apt-install python", "apt install python")],
|
|
)
|
|
def test_get_new_command(script, new_command):
|
|
assert get_new_command(Command(script, "")) == new_command
|