1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-08-13 17:49:51 +01:00
Files
.devcontainer
.github
scripts
tests
entrypoints
functional
output_readers
rules
__init__.py
test_adb_unknown_command.py
test_ag_literal.py
test_apt_get.py
test_apt_get_search.py
test_apt_invalid_operation.py
test_apt_list_upgradable.py
test_apt_upgrade.py
test_aws_cli.py
test_az_cli.py
test_brew_cask_dependency.py
test_brew_install.py
test_brew_link.py
test_brew_reinstall.py
test_brew_uninstall.py
test_brew_unknown_command.py
test_brew_update_formula.py
test_cargo_no_command.py
test_cat_dir.py
test_cd_correction.py
test_cd_cs.py
test_cd_mkdir.py
test_cd_parent.py
test_chmod_x.py
test_choco_install.py
test_composer_not_command.py
test_conda_mistype.py
test_cp_create_destination.py
test_cp_omitting_directory.py
test_dirty_untar.py
test_dirty_unzip.py
test_django_south_ghost.py
test_django_south_merge.py
test_dnf_no_such_command.py
test_docker_image_being_used_by_container.py
test_docker_login.py
test_docker_not_command.py
test_dry.py
test_fab_command_not_found.py
test_fix_alt_space.py
test_fix_file.py
test_gem_unknown_command.py
test_git_add.py
test_git_add_force.py
test_git_bisect_usage.py
test_git_branch_0flag.py
test_git_branch_delete.py
test_git_branch_delete_checked_out.py
test_git_branch_exists.py
test_git_branch_list.py
test_git_checkout.py
test_git_clone_git_clone.py
test_git_clone_missing.py
test_git_commit_add.py
test_git_commit_amend.py
test_git_commit_reset.py
test_git_diff_no_index.py
test_git_diff_staged.py
test_git_fix_stash.py
test_git_flag_after_filename.py
test_git_help_aliased.py
test_git_hook_bypass.py
test_git_lfs_mistype.py
test_git_main_master.py
test_git_merge.py
test_git_merge_unrelated.py
test_git_not_command.py
test_git_pull.py
test_git_pull_clone.py
test_git_pull_uncommitted_changes.py
test_git_pull_unstaged_changes.py
test_git_push.py
test_git_push_different_branch_names.py
test_git_push_force.py
test_git_push_pull.py
test_git_push_without_commits.py
test_git_rebase_merge_dir.py
test_git_rebase_no_changes.py
test_git_remote_delete.py
test_git_remote_seturl_add.py
test_git_rm_local_modifications.py
test_git_rm_recursive.py
test_git_rm_staged.py
test_git_stash.py
test_git_stash_pop.py
test_git_tag_force.py
test_git_two_dashes.py
test_go_run.py
test_go_unknown_command.py
test_gradle_not_task.py
test_gradle_wrapper.py
test_grep_arguments_order.py
test_grep_recursive.py
test_grunt_task_not_found.py
test_gulp_not_task.py
test_has_exists_script.py
test_heroku_multiple_apps.py
test_heroku_not_command.py
test_history.py
test_hostscli.py
test_ifconfig_device_not_found.py
test_java.py
test_javac.py
test_lein_not_task.py
test_ln_no_hard_link.py
test_ln_s_order.py
test_long_form_help.py
test_ls_all.py
test_ls_lah.py
test_man.py
test_man_no_space.py
test_mercurial.py
test_missing_space_before_subcommand.py
test_mkdir_p.py
test_mvn_no_command.py
test_mvn_unknown_lifecycle_phase.py
test_nixos_cmd_not_found.py
test_no_command.py
test_no_such_file.py
test_npm_missing_script.py
test_npm_run_script.py
test_npm_wrong_command.py
test_omnienv_no_such_command.py
test_open.py
test_pacman.py
test_pacman_invalid_option.py
test_pacman_not_found.py
test_path_from_history.py
test_php_s.py
test_pip_install.py
test_pip_unknown_command.py
test_port_already_in_use.py
test_prove_recursively.py
test_python_command.py
test_python_execute.py
test_python_module_error.py
test_quotation_marks.py
test_rails_migrations_pending.py
test_react_native_command_unrecognized.py
test_remove_shell_prompt_literal.py
test_remove_trailing_cedilla.py
test_rm_dir.py
test_rm_root.py
test_scm_correction.py
test_sed_unterminated_s.py
test_sl_ls.py
test_ssh_known_host.py
test_sudo.py
test_sudo_command_from_user_path.py
test_switch_lang.py
test_systemctl.py
test_terraform_init.py
test_terraform_no_command.py
test_tmux.py
test_touch.py
test_tsuru_login.py
test_tsuru_not_command.py
test_unknown_command.py
test_unsudo.py
test_vagrant_up.py
test_whois.py
test_workon_doesnt_exists.py
test_wrong_hyphen_before_subcommand.py
test_yarn_alias.py
test_yarn_command_not_found.py
test_yarn_command_replaced.py
test_yarn_help.py
test_yum_invalid_operation.py
shells
specific
Dockerfile
__init__.py
conftest.py
test_argument_parser.py
test_conf.py
test_corrector.py
test_logs.py
test_readme.py
test_types.py
test_ui.py
test_utils.py
utils.py
thefuck
.editorconfig
.gitignore
CONTRIBUTING.md
LICENSE.md
MANIFEST.in
README.md
example.gif
example_instant_mode.gif
fastentrypoints.py
install.sh
release.py
requirements.txt
setup.cfg
setup.py
snapcraft.yaml
tox.ini
thefuck/tests/rules/test_apt_list_upgradable.py
tobixx 3bbe391391 Only consider raw command in output ()
* 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
2019-08-19 21:39:14 +02:00

85 lines
3.8 KiB
Python

# -*- coding: utf-8 -*-
import pytest
from thefuck.rules.apt_list_upgradable import get_new_command, match
from thefuck.types import Command
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]
Hit:4 http://security.ubuntu.com/ubuntu zesty-security InRelease
Hit:5 http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu zesty InRelease
Hit:6 https://download.docker.com/linux/ubuntu zesty InRelease
Hit:7 https://cli-assets.heroku.com/branches/stable/apt ./ InRelease
Fetched 89.2 kB in 0s (122 kB/s)
Reading package lists... Done
Building dependency tree
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]
Get:3 http://us.archive.ubuntu.com/ubuntu zesty-backports InRelease [89.2 kB]
Get:4 http://security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
Hit:5 https://cli-assets.heroku.com/branches/stable/apt ./ InRelease
Hit:6 http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu zesty InRelease
Hit:7 https://download.docker.com/linux/ubuntu zesty InRelease
Get:8 http://us.archive.ubuntu.com/ubuntu zesty-updates/main i386 Packages [232 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu zesty-updates/main amd64 Packages [235 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu zesty-updates/main amd64 DEP-11 Metadata [55.2 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu zesty-updates/main DEP-11 64x64 Icons [32.3 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe amd64 Packages [156 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe i386 Packages [156 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe amd64 DEP-11 Metadata [175 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe DEP-11 64x64 Icons [253 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu zesty-updates/multiverse amd64 DEP-11 Metadata [5,840 B]
Get:17 http://us.archive.ubuntu.com/ubuntu zesty-backports/universe amd64 DEP-11 Metadata [4,588 B]
Get:18 http://security.ubuntu.com/ubuntu zesty-security/main amd64 DEP-11 Metadata [12.7 kB]
Get:19 http://security.ubuntu.com/ubuntu zesty-security/main DEP-11 64x64 Icons [17.6 kB]
Get:20 http://security.ubuntu.com/ubuntu zesty-security/universe amd64 DEP-11 Metadata [21.6 kB]
Get:21 http://security.ubuntu.com/ubuntu zesty-security/universe DEP-11 64x64 Icons [47.7 kB]
Get:22 http://security.ubuntu.com/ubuntu zesty-security/multiverse amd64 DEP-11 Metadata [208 B]
Fetched 1,673 kB in 0s (1,716 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
'''
@pytest.mark.parametrize('output', match_output)
def test_match(output):
assert match(Command('sudo apt update', output))
@pytest.mark.parametrize('command', [
Command('apt-cache search foo', ''),
Command('aptitude search foo', ''),
Command('apt search foo', ''),
Command('apt-get install foo', ''),
Command('apt-get source foo', ''),
Command('apt-get clean', ''),
Command('apt-get remove', ''),
Command('apt-get update', ''),
Command('sudo apt update', no_match_output)
])
def test_not_match(command):
assert not match(command)
@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', output))
assert new_command == 'apt list --upgradable'