1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-06-16 13:25:55 +01:00
Files
.devcontainer
.github
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_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_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
__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_sudo_command_from_user_path.py
2017-08-31 17:58:56 +02:00

40 lines
1.4 KiB
Python

import pytest
from thefuck.rules.sudo_command_from_user_path import match, get_new_command
from thefuck.types import Command
output = 'sudo: {}: command not found'
@pytest.fixture(autouse=True)
def which(mocker):
return mocker.patch('thefuck.rules.sudo_command_from_user_path.which',
return_value='/usr/bin/app')
@pytest.mark.parametrize('script, output', [
('sudo npm install -g react-native-cli', output.format('npm')),
('sudo -u app appcfg update .', output.format('appcfg'))])
def test_match(script, output):
assert match(Command(script, output))
@pytest.mark.parametrize('script, output, which_result', [
('npm --version', output.format('npm'), '/usr/bin/npm'),
('sudo npm --version', '', '/usr/bin/npm'),
('sudo npm --version', output.format('npm'), None)])
def test_not_match(which, script, output, which_result):
which.return_value = which_result
assert not match(Command(script, output))
@pytest.mark.parametrize('script, output, result', [
('sudo npm install -g react-native-cli',
output.format('npm'),
'sudo env "PATH=$PATH" npm install -g react-native-cli'),
('sudo -u app appcfg update .',
output.format('appcfg'),
'sudo -u app env "PATH=$PATH" appcfg update .')])
def test_get_new_command(script, output, result):
assert get_new_command(Command(script, output)) == result