mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	#N/A Move get_all_executables (formerly get_all_callables) to utils
				
					
				
			This commit is contained in:
		| @@ -18,7 +18,7 @@ def alias(mocker): | ||||
|  | ||||
| @pytest.fixture | ||||
| def callables(mocker): | ||||
|     return mocker.patch('thefuck.rules.history.get_all_callables', | ||||
|     return mocker.patch('thefuck.rules.history.get_all_executables', | ||||
|                         return_value=['diff', 'ls']) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,29 +1,16 @@ | ||||
| import pytest | ||||
| from thefuck.rules.no_command import match, get_new_command, get_all_callables | ||||
| from thefuck.rules.no_command import match, get_new_command | ||||
| from tests.utils import Command | ||||
|  | ||||
|  | ||||
| @pytest.fixture(autouse=True) | ||||
| def _safe(mocker): | ||||
|     mocker.patch('thefuck.rules.no_command._safe', return_value=[]) | ||||
|  | ||||
|  | ||||
| @pytest.fixture(autouse=True) | ||||
| def get_aliases(mocker): | ||||
|     mocker.patch('thefuck.rules.no_command.get_aliases', | ||||
|                  return_value=['vim', 'apt-get', 'fsck', 'fuck']) | ||||
| def get_all_executables(mocker): | ||||
|     mocker.patch('thefuck.rules.no_command.get_all_executables', | ||||
|                  return_value=['vim', 'apt-get', 'fsck']) | ||||
|  | ||||
|  | ||||
| @pytest.mark.usefixtures('no_memoize') | ||||
| def test_get_all_callables(*args): | ||||
|     all_callables = get_all_callables() | ||||
|     assert 'vim' in all_callables | ||||
|     assert 'fsck' in all_callables | ||||
|     assert 'fuck' not in all_callables | ||||
|  | ||||
|  | ||||
| @pytest.mark.usefixtures('no_memoize') | ||||
| def test_match(*args): | ||||
| def test_match(): | ||||
|     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) | ||||
| @@ -31,7 +18,7 @@ def test_match(*args): | ||||
|  | ||||
|  | ||||
| @pytest.mark.usefixtures('no_memoize') | ||||
| def test_get_new_command(*args): | ||||
| def test_get_new_command(): | ||||
|     assert get_new_command( | ||||
|         Command(stderr='vom: not found', | ||||
|                 script='vom file.py'), | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| import pytest | ||||
| from mock import Mock | ||||
| from thefuck.utils import git_support, sudo_support, wrap_settings, memoize, get_closest | ||||
| from thefuck.utils import git_support, sudo_support, wrap_settings,\ | ||||
|     memoize, get_closest, get_all_executables | ||||
| from thefuck.types import Settings | ||||
| from tests.utils import Command | ||||
|  | ||||
| @@ -63,3 +64,17 @@ class TestGetClosest(object): | ||||
|     def test_without_fallback(self): | ||||
|         assert get_closest('st', ['status', 'reset'], | ||||
|                            fallback_to_first=False) is None | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def get_aliases(mocker): | ||||
|     mocker.patch('thefuck.shells.get_aliases', | ||||
|                  return_value=['vim', 'apt-get', 'fsck', 'fuck']) | ||||
|  | ||||
|  | ||||
| @pytest.mark.usefixtures('no_memoize', 'get_aliases') | ||||
| def test_get_all_callables(): | ||||
|     all_callables = get_all_executables() | ||||
|     assert 'vim' in all_callables | ||||
|     assert 'fsck' in all_callables | ||||
|     assert 'fuck' not in all_callables | ||||
|   | ||||
		Reference in New Issue
	
	Block a user