예제 #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)
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'
예제 #6
0
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
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))
예제 #25
0
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
 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
 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={})