def test_from_script_calls(self, Popen, settings): settings.env = {} assert Command.from_raw_script( ['apt-get', 'search', 'vim']) == Command( 'apt-get search vim', 'stdout', 'stderr') Popen.assert_called_once_with('apt-get search vim', shell=True, stdout=PIPE, stderr=PIPE, env={})
def test_match(tar_error, filename, script, fixed): tar_error(filename) assert match(Command(script=script.format(filename)))
def test_match(script, stderr): assert match(Command(script, stderr=stderr), None)
def test_get_new_comman(script, result): new_command = get_new_command( Command(script, stderr=stderr.format('wlan0'))) assert new_command == result
def test_get_new_command(pip_unknown_cmd): assert get_new_command(Command('pip instatl', stderr=pip_unknown_cmd)) == 'pip install'
import pytest from theoops.rules.dry import match, get_new_command from tests.utils import Command @pytest.mark.parametrize('command', [ Command(script='cd cd foo'), Command(script='git git push origin/master')]) def test_match(command): assert match(command) @pytest.mark.parametrize('command, new_command', [ (Command('cd cd foo'), 'cd foo'), (Command('git git push origin/master'), 'git push origin/master')]) def test_get_new_command(command, new_command): assert get_new_command(command) == new_command
def test_match(script, file): assert match(Command(script, stderr=stderr(file)))
def test_not_match(script): assert not match(Command(script=script, stderr=''))
def test_get_new_command(is_not_task): assert get_new_command(Command(script='lein rpl --help', stderr=is_not_task)) \ == ['lein repl --help', 'lein jar --help']
def test_match(is_not_task): assert match(Command(script='lein rpl', stderr=is_not_task)) assert not match(Command(script='ls', stderr=is_not_task))
def test_get_new_command(script, result): assert get_new_command(Command(script, stdout)) == result
def test_not_match(script, stdout): assert not match(Command(script, stdout))
import pytest from thefuck.rules.mvn_unknown_lifecycle_phase import match, get_new_command from tests.utils import Command @pytest.mark.parametrize('command', [ Command( script='mvn cle', stdout= '[ERROR] Unknown lifecycle phase "cle". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]' ) ]) def test_match(command): assert match(command, None) @pytest.mark.parametrize('command', [ Command(script='mvn clean', stdout=""" [INFO] Scanning for projects...[INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building test 0.2 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test --- [INFO] Deleting /home/mlk/code/test/target [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.477s [INFO] Finished at: Wed Aug 26 13:05:47 BST 2015
import pytest from theoops.rules.python_execute import match, get_new_command from tests.utils import Command @pytest.mark.parametrize( 'command', [Command(script='python foo'), Command(script='python bar')]) def test_match(command): assert match(command) @pytest.mark.parametrize('command, new_command', [(Command('python foo'), 'python foo.py'), (Command('python bar'), 'python bar.py')]) def test_get_new_command(command, new_command): assert get_new_command(command) == new_command
def test_get_new_command(tar_error, filename, script, fixed): tar_error(filename) assert get_new_command( Command(script=script.format(filename))) == fixed.format(filename)
def test_match(stderr, stdout): assert match(Command(stderr=stderr, stdout=stdout))
def test_not_match(): assert not match(Command()) assert not match(Command(script='sudo ls', stderr='Permission denied'))
def test_get_new_command(stderr, new_command, script, formula): assert get_new_command(Command(script=script, stderr=stderr)) == new_command
def test_get_new_command(before, after): assert get_new_command(Command(before)) == after
def test_get_new_command(script, stderr, result): assert get_new_command(Command(script, stderr=stderr)) == result
def test_match(git_not_command, git_command, git_not_command_one_of_this): assert match(Command('git brnch', stderr=git_not_command), None) assert match(Command('git st', stderr=git_not_command_one_of_this), None) assert not match(Command('ls brnch', stderr=git_not_command), None) assert not match(Command('git branch', stderr=git_command), None)
def test_match(pip_unknown_cmd, pip_unknown_cmd_without_recommend): assert match(Command('pip instatl', stderr=pip_unknown_cmd)) assert not match(Command('pip i', stderr=pip_unknown_cmd_without_recommend))
def test_get_new_command(stderr): assert get_new_command(Command('git push', stderr=stderr))\ == "git push --set-upstream origin master" assert get_new_command(Command('git push --quiet', stderr=stderr))\ == "git push --set-upstream origin master --quiet"
def test_not_match(script, stderr): assert not match(Command(script, stderr=stderr))
def test_match(stderr): assert match(Command('git push', stderr=stderr)) assert match(Command('git push master', stderr=stderr)) assert not match(Command('git push master')) assert not match(Command('ls', stderr=stderr))
def test_get_new_command(): assert get_new_command(Command(script='cp dir'), None) == 'cp -a dir'
def test_get_new_command(script, stdout, new_command): assert get_new_command(Command(script=script, stdout=stdout)) == new_command
def test_get_new_command(): """ Replace the Alt+Space character by a simple space """ assert get_new_command(Command(u'ps -ef | grep foo'))\ == 'ps -ef | grep foo'
def test_match(script, stdout): assert match(Command(script=script, stdout=stdout))
def test_side_effect(tar_error, filename, script, fixed): tar_error(filename) side_effect(Command(script=script.format(filename)), None) assert set(os.listdir('.')) == {filename, 'd'}
def test_match(stderr, script): assert match(Command(script=script, stderr=stderr))
def test_from_script(self, script, result): if result: assert Command.from_raw_script(script).script == result else: with pytest.raises(EmptyCommand): Command.from_raw_script(script)
def test_from_script_calls(self, Popen, settings): settings.env = {} assert Command.from_raw_script(["apt-get", "search", "vim"]) == Command( "apt-get search vim", "stdout", "stderr" ) Popen.assert_called_once_with("apt-get search vim", shell=True, stdout=PIPE, stderr=PIPE, env={})