mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	#22 Get stderr and stdout with LANG=C
				
					
				
			This commit is contained in:
		| @@ -46,7 +46,9 @@ def test_get_rules(): | |||||||
|  |  | ||||||
|  |  | ||||||
| def test_get_command(): | def test_get_command(): | ||||||
|     with patch('thefuck.main.Popen') as Popen: |     with patch('thefuck.main.Popen') as Popen,\ | ||||||
|  |             patch('thefuck.main.os.environ', | ||||||
|  |                   new_callable=lambda: {}): | ||||||
|         Popen.return_value.stdout.read.return_value = b'stdout' |         Popen.return_value.stdout.read.return_value = b'stdout' | ||||||
|         Popen.return_value.stderr.read.return_value = b'stderr' |         Popen.return_value.stderr.read.return_value = b'stderr' | ||||||
|         assert main.get_command(['thefuck', 'apt-get', 'search', 'vim']) \ |         assert main.get_command(['thefuck', 'apt-get', 'search', 'vim']) \ | ||||||
| @@ -54,7 +56,8 @@ def test_get_command(): | |||||||
|         Popen.assert_called_once_with('apt-get search vim', |         Popen.assert_called_once_with('apt-get search vim', | ||||||
|                                       shell=True, |                                       shell=True, | ||||||
|                                       stdout=PIPE, |                                       stdout=PIPE, | ||||||
|                                       stderr=PIPE) |                                       stderr=PIPE, | ||||||
|  |                                       env={'LANG': 'C'}) | ||||||
|  |  | ||||||
|  |  | ||||||
| def test_get_matched_rule(): | def test_get_matched_rule(): | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ from imp import load_source | |||||||
| from pathlib import Path | from pathlib import Path | ||||||
| from os.path import expanduser | from os.path import expanduser | ||||||
| from subprocess import Popen, PIPE | from subprocess import Popen, PIPE | ||||||
|  | import os | ||||||
| import sys | import sys | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -56,7 +57,8 @@ def get_rules(user_dir, settings): | |||||||
| def get_command(args): | def get_command(args): | ||||||
|     """Creates command from `args` and executes it.""" |     """Creates command from `args` and executes it.""" | ||||||
|     script = ' '.join(args[1:]) |     script = ' '.join(args[1:]) | ||||||
|     result = Popen(script, shell=True, stdout=PIPE, stderr=PIPE) |     result = Popen(script, shell=True, stdout=PIPE, stderr=PIPE, | ||||||
|  |                    env=dict(os.environ, LANG='C')) | ||||||
|     return Command(script, result.stdout.read().decode('utf-8'), |     return Command(script, result.stdout.read().decode('utf-8'), | ||||||
|                    result.stderr.read().decode('utf-8')) |                    result.stderr.read().decode('utf-8')) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user