mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	#N/A: Add tests for tcsh
This commit is contained in:
		
							
								
								
									
										60
									
								
								tests/shells/test_tcsh.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								tests/shells/test_tcsh.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| import pytest | ||||
| from thefuck.shells.tcsh import Tcsh | ||||
|  | ||||
|  | ||||
| @pytest.mark.usefixtures('isfile') | ||||
| class TestTcsh(object): | ||||
|     @pytest.fixture | ||||
|     def shell(self): | ||||
|         return Tcsh() | ||||
|  | ||||
|     @pytest.fixture(autouse=True) | ||||
|     def Popen(self, mocker): | ||||
|         mock = mocker.patch('thefuck.shells.tcsh.Popen') | ||||
|         mock.return_value.stdout.read.return_value = ( | ||||
|             b'fuck\teval $(thefuck $(fc -ln -1))\n' | ||||
|             b'l\tls -CF\n' | ||||
|             b'la\tls -A\n' | ||||
|             b'll\tls -alF') | ||||
|         return mock | ||||
|  | ||||
|     @pytest.mark.parametrize('before, after', [ | ||||
|         ('pwd', 'pwd'), | ||||
|         ('fuck', 'eval $(thefuck $(fc -ln -1))'), | ||||
|         ('awk', 'awk'), | ||||
|         ('ll', 'ls -alF')]) | ||||
|     def test_from_shell(self, before, after, shell): | ||||
|         assert shell.from_shell(before) == after | ||||
|  | ||||
|     def test_to_shell(self, shell): | ||||
|         assert shell.to_shell('pwd') == 'pwd' | ||||
|  | ||||
|     @pytest.mark.parametrize('entry, entry_utf8', [ | ||||
|         ('ls', '#+1430707243\nls\n'), | ||||
|         (u'echo café', '#+1430707243\necho café\n')]) | ||||
|     def test_put_to_history(self, entry, entry_utf8, builtins_open, shell, mocker): | ||||
|         mocker.patch('thefuck.shells.tcsh.time', | ||||
|                      return_value=1430707243.3517463) | ||||
|         shell.put_to_history(entry) | ||||
|         builtins_open.return_value.__enter__.return_value. \ | ||||
|             write.assert_called_once_with(entry_utf8) | ||||
|  | ||||
|     def test_and_(self, shell): | ||||
|         assert shell.and_('ls', 'cd') == 'ls && cd' | ||||
|  | ||||
|     def test_get_aliases(self, shell): | ||||
|         assert shell.get_aliases() == {'fuck': 'eval $(thefuck $(fc -ln -1))', | ||||
|                                        'l': 'ls -CF', | ||||
|                                        'la': 'ls -A', | ||||
|                                        'll': 'ls -alF'} | ||||
|  | ||||
|     def test_app_alias(self, shell): | ||||
|         assert 'alias fuck' in shell.app_alias('fuck') | ||||
|         assert 'alias FUCK' in shell.app_alias('FUCK') | ||||
|         assert 'thefuck' in shell.app_alias('fuck') | ||||
|  | ||||
|     def test_get_history(self, history_lines, shell): | ||||
|         history_lines(['ls', 'rm']) | ||||
|         assert list(shell.get_history()) == ['ls', 'rm'] | ||||
		Reference in New Issue
	
	Block a user