コード例 #1
0
ファイル: test_types.py プロジェクト: DJMIN/thefuck
 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={})
コード例 #2
0
def test_match(tar_error, filename, script, fixed):
    tar_error(filename)
    assert match(Command(script=script.format(filename)))
コード例 #3
0
def test_match(script, stderr):
    assert match(Command(script, stderr=stderr), None)
コード例 #4
0
def test_get_new_comman(script, result):
    new_command = get_new_command(
        Command(script, stderr=stderr.format('wlan0')))
    assert new_command == result
コード例 #5
0
def test_get_new_command(pip_unknown_cmd):
    assert get_new_command(Command('pip instatl',
                                   stderr=pip_unknown_cmd)) == 'pip install'
コード例 #6
0
ファイル: test_dry.py プロジェクト: samzhang111/oops
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
コード例 #7
0
def test_match(script, file):
    assert match(Command(script, stderr=stderr(file)))
コード例 #8
0
def test_not_match(script):
    assert not match(Command(script=script, stderr=''))
コード例 #9
0
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']
コード例 #10
0
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))
コード例 #11
0
def test_get_new_command(script, result):
    assert get_new_command(Command(script, stdout)) == result
コード例 #12
0
def test_not_match(script, stdout):
    assert not match(Command(script, stdout))
コード例 #13
0
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
コード例 #14
0
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
コード例 #15
0
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)
コード例 #16
0
def test_match(stderr, stdout):
    assert match(Command(stderr=stderr, stdout=stdout))
コード例 #17
0
def test_not_match():
    assert not match(Command())
    assert not match(Command(script='sudo ls', stderr='Permission denied'))
コード例 #18
0
def test_get_new_command(stderr, new_command, script, formula):
    assert get_new_command(Command(script=script,
                                   stderr=stderr)) == new_command
コード例 #19
0
def test_get_new_command(before, after):
    assert get_new_command(Command(before)) == after
コード例 #20
0
def test_get_new_command(script, stderr, result):
    assert get_new_command(Command(script, stderr=stderr)) == result
コード例 #21
0
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)
コード例 #22
0
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))
コード例 #23
0
ファイル: test_git_push.py プロジェクト: xiaojiaose/thefuck
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"
コード例 #24
0
def test_not_match(script, stderr):
    assert not match(Command(script, stderr=stderr))
コード例 #25
0
ファイル: test_git_push.py プロジェクト: mengdaya/fuckshell
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))
コード例 #26
0
def test_get_new_command():
    assert get_new_command(Command(script='cp dir'), None) == 'cp -a dir'
コード例 #27
0
def test_get_new_command(script, stdout, new_command):
    assert get_new_command(Command(script=script,
                                   stdout=stdout)) == new_command
コード例 #28
0
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'
コード例 #29
0
def test_match(script, stdout):
    assert match(Command(script=script, stdout=stdout))
コード例 #30
0
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'}
コード例 #31
0
def test_match(stderr, script):
    assert match(Command(script=script, stderr=stderr))
コード例 #32
0
ファイル: test_types.py プロジェクト: ispiders/thefuck
 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)
コード例 #33
0
ファイル: test_types.py プロジェクト: chishi2612/thefuck
 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={})