From 3bbe391391d3f54d4ad8b3bc4bdf594ffbe4388d Mon Sep 17 00:00:00 2001 From: tobixx Date: Mon, 19 Aug 2019 21:39:14 +0200 Subject: [PATCH] Only consider raw command in output (#931) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Only consider raw command in output match ... else it will not work for localized messages. Example German output: ``` Führen Sie »apt list --upgradable« aus, um sie anzuzeigen. ``` * added german output test * make the linter happy --- tests/rules/test_apt_list_upgradable.py | 21 +++++++++++++++------ thefuck/rules/apt_list_upgradable.py | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/rules/test_apt_list_upgradable.py b/tests/rules/test_apt_list_upgradable.py index 257a92a0..fdb9168d 100644 --- a/tests/rules/test_apt_list_upgradable.py +++ b/tests/rules/test_apt_list_upgradable.py @@ -1,8 +1,10 @@ +# -*- coding: utf-8 -*- + import pytest from thefuck.rules.apt_list_upgradable import get_new_command, match from thefuck.types import Command -match_output = ''' +full_english_output = ''' Hit:1 http://us.archive.ubuntu.com/ubuntu zesty InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu zesty-updates InRelease Get:3 http://us.archive.ubuntu.com/ubuntu zesty-backports InRelease [89.2 kB] @@ -17,6 +19,11 @@ Reading state information... Done 8 packages can be upgraded. Run 'apt list --upgradable' to see them. ''' +match_output = [ + full_english_output, + 'Führen Sie »apt list --upgradable« aus, um sie anzuzeigen.' # German +] + no_match_output = ''' Hit:1 http://us.archive.ubuntu.com/ubuntu zesty InRelease Get:2 http://us.archive.ubuntu.com/ubuntu zesty-updates InRelease [89.2 kB] @@ -48,8 +55,9 @@ All packages are up to date. ''' -def test_match(): - assert match(Command('sudo apt update', match_output)) +@pytest.mark.parametrize('output', match_output) +def test_match(output): + assert match(Command('sudo apt update', output)) @pytest.mark.parametrize('command', [ @@ -67,9 +75,10 @@ def test_not_match(command): assert not match(command) -def test_get_new_command(): - new_command = get_new_command(Command('sudo apt update', match_output)) +@pytest.mark.parametrize('output', match_output) +def test_get_new_command(output): + new_command = get_new_command(Command('sudo apt update', output)) assert new_command == 'sudo apt list --upgradable' - new_command = get_new_command(Command('apt update', match_output)) + new_command = get_new_command(Command('apt update', output)) assert new_command == 'apt list --upgradable' diff --git a/thefuck/rules/apt_list_upgradable.py b/thefuck/rules/apt_list_upgradable.py index 071a7483..128c8231 100644 --- a/thefuck/rules/apt_list_upgradable.py +++ b/thefuck/rules/apt_list_upgradable.py @@ -8,7 +8,7 @@ enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): - return "Run 'apt list --upgradable' to see them." in command.output + return 'apt list --upgradable' in command.output @sudo_support