mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 02:01:13 +00:00
#994: Replace decoding errors with the replacement marker
Fix #994 Reference: https://docs.python.org/3/library/codecs.html#error-handlers
This commit is contained in:
parent
eb05b28c5b
commit
c2df71caed
@ -22,6 +22,14 @@ class TestRerun(object):
|
|||||||
assert rerun.get_output('', '') is None
|
assert rerun.get_output('', '') is None
|
||||||
wait_output_mock.assert_called_once()
|
wait_output_mock.assert_called_once()
|
||||||
|
|
||||||
|
@patch('thefuck.output_readers.rerun.Popen')
|
||||||
|
def test_get_output_invalid_continuation_byte(self, popen_mock):
|
||||||
|
output = b'ls: illegal option -- \xc3\nusage: ls [-@ABC...] [file ...]\n'
|
||||||
|
expected = u'ls: illegal option -- \ufffd\nusage: ls [-@ABC...] [file ...]\n'
|
||||||
|
popen_mock.return_value.stdout.read.return_value = output
|
||||||
|
actual = rerun.get_output('', '')
|
||||||
|
assert actual == expected
|
||||||
|
|
||||||
def test_wait_output_is_slow(self, settings):
|
def test_wait_output_is_slow(self, settings):
|
||||||
assert rerun._wait_output(Mock(), True)
|
assert rerun._wait_output(Mock(), True)
|
||||||
self.proc_mock.wait.assert_called_once_with(settings.wait_slow_command)
|
self.proc_mock.wait.assert_called_once_with(settings.wait_slow_command)
|
||||||
|
@ -60,7 +60,7 @@ def get_output(script, expanded):
|
|||||||
result = Popen(expanded, shell=True, stdin=PIPE,
|
result = Popen(expanded, shell=True, stdin=PIPE,
|
||||||
stdout=PIPE, stderr=STDOUT, env=env)
|
stdout=PIPE, stderr=STDOUT, env=env)
|
||||||
if _wait_output(result, is_slow):
|
if _wait_output(result, is_slow):
|
||||||
output = result.stdout.read().decode('utf-8')
|
output = result.stdout.read().decode('utf-8', errors='replace')
|
||||||
logs.debug(u'Received output: {}'.format(output))
|
logs.debug(u'Received output: {}'.format(output))
|
||||||
return output
|
return output
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user