Пример #1
0
def test_match():
    with patch('thefuck.rules.no_command._get_all_bins',
               return_value=['vim', 'apt-get']):
        assert match(Mock(stderr='vom: not found', script='vom file.py'), None)
        assert not match(Mock(stderr='qweqwe: not found', script='qweqwe'),
                         None)
        assert not match(Mock(stderr='some text', script='vom file.py'), None)
Пример #2
0
def test_match(command_found, command_not_found, settings):
    with patch('thefuck.rules.no_command.Popen') as Popen:
        Popen.return_value.stderr.read.return_value = command_found
        assert match(Command('aptget install vim', '', ''), settings)
        Popen.assert_called_once_with('/usr/lib/command-not-found aptget',
                                      shell=True,
                                      stderr=PIPE)
        Popen.return_value.stderr.read.return_value = command_not_found
        assert not match(Command('ls', '', ''), settings)

    with patch('thefuck.rules.no_command.Popen') as Popen:
        Popen.return_value.stderr.read.return_value = command_found
        assert match(Command('sudo aptget install vim', '', ''),
                     Mock(command_not_found='test'))
        Popen.assert_called_once_with('test aptget', shell=True, stderr=PIPE)
Пример #3
0
def test_match(command_found, command_not_found, settings):
    with patch('thefuck.rules.no_command.Popen') as Popen:
        Popen.return_value.stderr.read.return_value = command_found
        assert match(Command('aptget install vim', '', ''), settings)
        Popen.assert_called_once_with('/usr/lib/command-not-found aptget',
                                      shell=True, stderr=PIPE)
        Popen.return_value.stderr.read.return_value = command_not_found
        assert not match(Command('ls', '', ''), settings)

    with patch('thefuck.rules.no_command.Popen') as Popen:
        Popen.return_value.stderr.read.return_value = command_found
        assert match(Command('sudo aptget install vim', '', ''),
                     Mock(command_not_found='test'))
        Popen.assert_called_once_with('test aptget',
                                      shell=True, stderr=PIPE)
Пример #4
0
def test_match(*args):
    assert match(Command(stderr='vom: not found', script='vom file.py'), None)
    assert match(Command(stderr='fucck: not found', script='fucck'), None)
    assert not match(Command(stderr='qweqwe: not found', script='qweqwe'), None)
    assert not match(Command(stderr='some text', script='vom file.py'), None)
Пример #5
0
def test_not_match(mocker, script, stderr, which):
    mocker.patch('thefuck.rules.no_command.which', return_value=which)

    assert not match(Command(script, stderr=stderr))
Пример #6
0
def test_match():
    with patch('thefuck.rules.no_command._get_all_callables',
               return_value=['vim', 'apt-get']):
        assert match(Mock(stderr='vom: not found', script='vom file.py'), None)
        assert not match(Mock(stderr='qweqwe: not found', script='qweqwe'), None)
        assert not match(Mock(stderr='some text', script='vom file.py'), None)
Пример #7
0
def test_not_match(mocker, script, output, which):
    mocker.patch("thefuck.rules.no_command.which", return_value=which)

    assert not match(Command(script, output))
Пример #8
0
def test_match(mocker, script, output):
    mocker.patch('thefuck.rules.no_command.which', return_value=None)

    assert match(Command(script, output))
Пример #9
0
def test_match():
    assert match(Command(stderr='vom: not found', script='vom file.py'))
    assert match(Command(stderr='fucck: not found', script='fucck'))
    assert not match(Command(stderr='qweqwe: not found', script='qweqwe'))
    assert not match(Command(stderr='some text', script='vom file.py'))
Пример #10
0
def test_not_match(script, stderr):
    assert not match(Command(script, stderr=stderr))
Пример #11
0
def test_not_match(mocker, script, stderr, which):
    mocker.patch('thefuck.rules.no_command.which', return_value=which)

    assert not match(Command(script, stderr=stderr))
Пример #12
0
def test_match(mocker, script, output):
    mocker.patch('thefuck.rules.no_command.which', return_value=None)

    assert match(Command(script, output))
Пример #13
0
def test_not_match(script, stderr):
    assert not match(Command(script, stderr=stderr))
Пример #14
0
def test_match(*args):
    assert match(Mock(stderr='vom: not found', script='vom file.py'), None)
    assert match(Mock(stderr='fucck: not found', script='fucck'), None)
    assert not match(Mock(stderr='qweqwe: not found', script='qweqwe'), None)
    assert not match(Mock(stderr='some text', script='vom file.py'), None)