1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 10:51:11 +01:00
thefuck/tests/rules/test_no_command.py

20 lines
751 B
Python
Raw Normal View History

2015-04-17 15:24:03 +01:00
from mock import patch, Mock
from thefuck.rules.no_command import match, get_new_command
2015-04-08 18:00:03 +01:00
2015-04-21 05:55:47 +01:00
def test_match():
with patch('thefuck.rules.no_command._get_all_callables',
2015-04-21 05:55:47 +01:00
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)
2015-04-08 18:00:03 +01:00
2015-04-21 05:55:47 +01:00
def test_get_new_command():
with patch('thefuck.rules.no_command._get_all_callables',
2015-04-21 05:55:47 +01:00
return_value=['vim', 'apt-get']):
assert get_new_command(
Mock(stderr='vom: not found',
script='vom file.py'),
None) == 'vim file.py'