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)
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)
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)
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))
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)
def test_not_match(mocker, script, output, which): mocker.patch("thefuck.rules.no_command.which", return_value=which) assert not match(Command(script, output))
def test_match(mocker, script, output): mocker.patch('thefuck.rules.no_command.which', return_value=None) assert match(Command(script, output))
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'))
def test_not_match(script, stderr): assert not match(Command(script, stderr=stderr))
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)