mirror of
https://github.com/nvbn/thefuck.git
synced 2025-07-09 00:23:30 +01:00
tests
functional
rules
__init__.py
test_ag_literal.py
test_apt_get.py
test_apt_get_search.py
test_apt_invalid_operation.py
test_aws_cli.py
test_brew_install.py
test_brew_link.py
test_brew_uninstall.py
test_brew_unknown_command.py
test_brew_update_formula.py
test_brew_upgrade.py
test_cargo_no_command.py
test_cd_mkdir.py
test_cd_parent.py
test_chmod_x.py
test_composer_not_command.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_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_delete.py
test_git_branch_exists.py
test_git_branch_list.py
test_git_checkout.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_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_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_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_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_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_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_no_command.py
test_no_such_file.py
test_npm_missing_script.py
test_npm_run_script.py
test_npm_wrong_command.py
test_open.py
test_pacman.py
test_pacman_not_found.py
test_path_from_history.py
test_pip_unknown_command.py
test_port_already_in_use.py
test_python_command.py
test_python_execute.py
test_quotation_marks.py
test_react_native_command_unrecognized.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_tmux.py
test_touch.py
test_tsuru_login.py
test_tsuru_not_command.py
test_unknown_command.py
test_vagrant_up.py
test_whois.py
test_workon_doesnt_exists.py
test_yarn_alias.py
test_yarn_command_not_found.py
test_yarn_command_replaced.py
test_yarn_help.py
shells
specific
__init__.py
conftest.py
test_argument_parser.py
test_conf.py
test_corrector.py
test_logs.py
test_not_configured.py
test_readme.py
test_types.py
test_ui.py
test_utils.py
utils.py
thefuck
.gitignore
.travis.yml
CONTRIBUTING.md
LICENSE.md
MANIFEST.in
README.md
appveyor.yml
example.gif
fastentrypoints.py
install.sh
release.py
requirements.txt
setup.cfg
setup.py
tox.ini
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
import pytest
|
|
from thefuck.rules.sudo_command_from_user_path import match, get_new_command
|
|
from tests.utils import Command
|
|
|
|
|
|
stderr = '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, stderr', [
|
|
('sudo npm install -g react-native-cli', stderr.format('npm')),
|
|
('sudo -u app appcfg update .', stderr.format('appcfg'))])
|
|
def test_match(script, stderr):
|
|
assert match(Command(script, stderr=stderr))
|
|
|
|
|
|
@pytest.mark.parametrize('script, stderr, which_result', [
|
|
('npm --version', stderr.format('npm'), '/usr/bin/npm'),
|
|
('sudo npm --version', '', '/usr/bin/npm'),
|
|
('sudo npm --version', stderr.format('npm'), None)])
|
|
def test_not_match(which, script, stderr, which_result):
|
|
which.return_value = which_result
|
|
assert not match(Command(script, stderr=stderr))
|
|
|
|
|
|
@pytest.mark.parametrize('script, stderr, result', [
|
|
('sudo npm install -g react-native-cli',
|
|
stderr.format('npm'),
|
|
'sudo env "PATH=$PATH" npm install -g react-native-cli'),
|
|
('sudo -u app appcfg update .',
|
|
stderr.format('appcfg'),
|
|
'sudo -u app env "PATH=$PATH" appcfg update .')])
|
|
def test_get_new_command(script, stderr, result):
|
|
assert get_new_command(Command(script, stderr=stderr)) == result
|