mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Merge pull request #561 from josephfrazier/ag-literal
Suggest `ag -Q` when relevant
This commit is contained in:
		
							
								
								
									
										25
									
								
								tests/rules/test_ag_literal.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								tests/rules/test_ag_literal.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| import pytest | ||||
| from thefuck.rules.ag_literal import get_new_command, match | ||||
| from tests.utils import Command | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def stderr(): | ||||
|     return ('ERR: Bad regex! pcre_compile() failed at position 1: missing )\n' | ||||
|             'If you meant to search for a literal string, run ag with -Q\n') | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script', ['ag \(']) | ||||
| def test_match(script, stderr): | ||||
|     assert match(Command(script=script, stderr=stderr)) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script', ['ag foo']) | ||||
| def test_not_match(script): | ||||
|     assert not match(Command(script=script)) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script, new_cmd', [ | ||||
|     ('ag \(', 'ag -Q \(')]) | ||||
| def test_get_new_command(script, new_cmd, stderr): | ||||
|     assert get_new_command((Command(script=script, stderr=stderr))) == new_cmd | ||||
		Reference in New Issue
	
	Block a user