mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Adding unittest for cd_correction (with extra fish test case, also for cd_mkdir)
This commit is contained in:
		
							
								
								
									
										23
									
								
								tests/rules/test_cd_correction.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								tests/rules/test_cd_correction.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | import pytest | ||||||
|  | from thefuck.rules.cd_correction import match, get_new_command | ||||||
|  | from thefuck.types import Command | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @pytest.mark.parametrize('command', [ | ||||||
|  |     Command('cd foo', 'cd: foo: No such file or directory'), | ||||||
|  |     Command('cd foo/bar/baz', | ||||||
|  |             'cd: foo: No such file or directory'), | ||||||
|  |     Command('cd foo/bar/baz', 'cd: can\'t cd to foo/bar/baz'), | ||||||
|  |     Command('cd /foo/bar/', 'cd: The directory "/foo/bar/" does not exist')]) | ||||||
|  | def test_match(command): | ||||||
|  |     assert match(command) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @pytest.mark.parametrize('command', [ | ||||||
|  |     Command('cd foo', ''), Command('', '')]) | ||||||
|  | def test_not_match(command): | ||||||
|  |     assert not match(command) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # Note that get_new_command uses local filesystem, so not testing it here. | ||||||
|  | # Instead, see the functional test `functional.test_cd_correction` | ||||||
| @@ -7,7 +7,8 @@ from thefuck.types import Command | |||||||
|     Command('cd foo', 'cd: foo: No such file or directory'), |     Command('cd foo', 'cd: foo: No such file or directory'), | ||||||
|     Command('cd foo/bar/baz', |     Command('cd foo/bar/baz', | ||||||
|             'cd: foo: No such file or directory'), |             'cd: foo: No such file or directory'), | ||||||
|     Command('cd foo/bar/baz', 'cd: can\'t cd to foo/bar/baz')]) |     Command('cd foo/bar/baz', 'cd: can\'t cd to foo/bar/baz'), | ||||||
|  |     Command('cd /foo/bar/', 'cd: The directory "/foo/bar/" does not exist')]) | ||||||
| def test_match(command): | def test_match(command): | ||||||
|     assert match(command) |     assert match(command) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user