mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	#611: Allow to configure alias automatically by calling fuck twice
				
					
				
			This commit is contained in:
		| @@ -20,3 +20,11 @@ def history_lines(mocker): | ||||
|             .return_value.readlines.return_value = lines | ||||
|  | ||||
|     return aux | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def config_exists(mocker): | ||||
|     path_mock = mocker.patch('thefuck.shells.generic.Path') | ||||
|     return path_mock.return_value \ | ||||
|         .expanduser.return_value \ | ||||
|         .exists | ||||
|   | ||||
| @@ -61,3 +61,12 @@ class TestBash(object): | ||||
|         command = 'git log -p' | ||||
|         command_parts = ['git', 'log', '-p'] | ||||
|         assert shell.split_command(command) == command_parts | ||||
|  | ||||
|     def test_how_to_configure(self, shell, config_exists): | ||||
|         config_exists.return_value = True | ||||
|         assert shell.how_to_configure().can_configure_automatically | ||||
|  | ||||
|     def test_how_to_configure_when_config_not_found(self, shell, | ||||
|                                                     config_exists): | ||||
|         config_exists.return_value = False | ||||
|         assert not shell.how_to_configure().can_configure_automatically | ||||
|   | ||||
| @@ -95,3 +95,12 @@ class TestFish(object): | ||||
|         shell.put_to_history(entry) | ||||
|         builtins_open.return_value.__enter__.return_value. \ | ||||
|             write.assert_called_once_with(entry_utf8) | ||||
|  | ||||
|     def test_how_to_configure(self, shell, config_exists): | ||||
|         config_exists.return_value = True | ||||
|         assert shell.how_to_configure().can_configure_automatically | ||||
|  | ||||
|     def test_how_to_configure_when_config_not_found(self, shell, | ||||
|                                                     config_exists): | ||||
|         config_exists.return_value = False | ||||
|         assert not shell.how_to_configure().can_configure_automatically | ||||
|   | ||||
| @@ -37,3 +37,6 @@ class TestGeneric(object): | ||||
|     def test_split_command(self, shell): | ||||
|         assert shell.split_command('ls') == ['ls'] | ||||
|         assert shell.split_command(u'echo café') == [u'echo', u'café'] | ||||
|  | ||||
|     def test_how_to_configure(self, shell): | ||||
|         assert shell.how_to_configure() is None | ||||
|   | ||||
| @@ -17,3 +17,6 @@ class TestPowershell(object): | ||||
|         assert 'function fuck' in shell.app_alias('fuck') | ||||
|         assert 'function FUCK' in shell.app_alias('FUCK') | ||||
|         assert 'thefuck' in shell.app_alias('fuck') | ||||
|  | ||||
|     def test_how_to_configure(self, shell): | ||||
|         assert not shell.how_to_configure().can_configure_automatically | ||||
|   | ||||
| @@ -48,3 +48,12 @@ class TestTcsh(object): | ||||
|     def test_get_history(self, history_lines, shell): | ||||
|         history_lines(['ls', 'rm']) | ||||
|         assert list(shell.get_history()) == ['ls', 'rm'] | ||||
|  | ||||
|     def test_how_to_configure(self, shell, config_exists): | ||||
|         config_exists.return_value = True | ||||
|         assert shell.how_to_configure().can_configure_automatically | ||||
|  | ||||
|     def test_how_to_configure_when_config_not_found(self, shell, | ||||
|                                                     config_exists): | ||||
|         config_exists.return_value = False | ||||
|         assert not shell.how_to_configure().can_configure_automatically | ||||
|   | ||||
| @@ -55,3 +55,12 @@ class TestZsh(object): | ||||
|     def test_get_history(self, history_lines, shell): | ||||
|         history_lines([': 1432613911:0;ls', ': 1432613916:0;rm']) | ||||
|         assert list(shell.get_history()) == ['ls', 'rm'] | ||||
|  | ||||
|     def test_how_to_configure(self, shell, config_exists): | ||||
|         config_exists.return_value = True | ||||
|         assert shell.how_to_configure().can_configure_automatically | ||||
|  | ||||
|     def test_how_to_configure_when_config_not_found(self, shell, | ||||
|                                                     config_exists): | ||||
|         config_exists.return_value = False | ||||
|         assert not shell.how_to_configure().can_configure_automatically | ||||
|   | ||||
		Reference in New Issue
	
	Block a user