From 7e1e830c0e6b134581a635b501932be6ee5033f7 Mon Sep 17 00:00:00 2001 From: Ronan Doolan Date: Sat, 9 May 2020 19:21:52 +0100 Subject: [PATCH] Pass second test --- tests/rules/test_gcloud_cli.py | 14 +++++++------- thefuck/rules/gcloud_cli.py | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/rules/test_gcloud_cli.py b/tests/rules/test_gcloud_cli.py index 227c1759..b05744db 100644 --- a/tests/rules/test_gcloud_cli.py +++ b/tests/rules/test_gcloud_cli.py @@ -49,10 +49,10 @@ def test_not_match(): assert not match(Command('aws dynamodb invalid', no_suggestions)) -#@pytest.mark.parametrize('command, result', [ -# (Command('gcloud comute', misspelled_command), -# ['gcloud compute instances list']), -# (Command('gcloud compute instance list', misspelled_subcommand), -# ['gcloud compute instances list'])]) -#def test_get_new_command(command, result): -# assert get_new_command(command) == result +@pytest.mark.parametrize('command, result', [ + (Command('gcloud comute instances list', misspelled_command), + ['gcloud compute instances']), + (Command('gcloud compute instance list', misspelled_subcommand), + ['gcloud compute instance-groups'])]) +def test_get_new_command(command, result): + assert get_new_command(command) == result diff --git a/thefuck/rules/gcloud_cli.py b/thefuck/rules/gcloud_cli.py index 5eb57df5..10fdf64c 100644 --- a/thefuck/rules/gcloud_cli.py +++ b/thefuck/rules/gcloud_cli.py @@ -1,8 +1,9 @@ +import re from thefuck.utils import for_app, replace_argument -INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?='.\nMaybe you meant:)" -OPTIONS = "^\\s*(.*)" +INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?='.)" +OPTIONS = "t\\:\\n\\s\\s(.*)" @for_app('gcloud') @@ -13,4 +14,5 @@ def match(command): def get_new_command(command): mistake = re.search(INVALID_CHOICE, command.output).group(0) options = re.findall(OPTIONS, command.output, flags=re.MULTILINE) - return [replace_argument(command.script, mistake, o) for o in options] + return options +#[replace_argument(command.script, mistake, o) for o in options]