From dfd0be20027dd808073a4ac7e98d234c68472f3a Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Sun, 8 Oct 2017 18:54:37 -0300 Subject: [PATCH] #701: Replace the first single occurrence of `delete` --- tests/rules/test_git_remote_delete.py | 9 ++++++--- thefuck/rules/git_remote_delete.py | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/rules/test_git_remote_delete.py b/tests/rules/test_git_remote_delete.py index 660f0c8b..b7a1e4f2 100644 --- a/tests/rules/test_git_remote_delete.py +++ b/tests/rules/test_git_remote_delete.py @@ -16,6 +16,9 @@ def test_not_match(command): assert not match(command) -def test_get_new_command(): - new_command = get_new_command(Command('git remote delete foo', '')) - assert new_command == 'git remote remove foo' +@pytest.mark.parametrize('command, new_command', [ + (Command('git remote delete foo', ''), 'git remote remove foo'), + (Command('git remote delete delete', ''), 'git remote remove delete'), +]) +def test_get_new_command(command, new_command): + assert get_new_command(command) == new_command diff --git a/thefuck/rules/git_remote_delete.py b/thefuck/rules/git_remote_delete.py index ce316da1..57f22dc8 100644 --- a/thefuck/rules/git_remote_delete.py +++ b/thefuck/rules/git_remote_delete.py @@ -1,4 +1,5 @@ -from thefuck.utils import replace_argument +import re + from thefuck.specific.git import git_support @@ -9,4 +10,4 @@ def match(command): @git_support def get_new_command(command): - return replace_argument(command.script, "delete", "remove") + return re.sub(r"delete", "remove", command.script, 1)