From bccde9a183c1baca3c00f3f2fc005748fe660df6 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Wed, 19 Oct 2022 15:11:04 +0300 Subject: [PATCH] Add a test case for ignoring decode errors with fd/file_chunk_consumer Also added some latin-1 encoded bytes to make it always invalid for sys.stdout too. --- test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index df10ebd8..a8aca800 100644 --- a/test.py +++ b/test.py @@ -2160,9 +2160,9 @@ def test_decode_error_handling(self): sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb') IS_PY3 = sys.version_info[0] == 3 if IS_PY3: - sys.stdout.write(bytes("te漢字st", "utf8")) + sys.stdout.write(bytes("te漢字st", "utf8") + "äåéë".encode("latin_1")) else: - sys.stdout.write("te漢字st") + sys.stdout.write("te漢字st" + u"äåéë".encode("latin_1")) """) fn = partial(python, py.name, _encoding="ascii") @@ -2173,6 +2173,9 @@ def s(fn): str(fn()) p = python(py.name, _encoding="ascii", _decode_errors="ignore") self.assertEqual(p, "test") + p = python(py.name, _encoding="ascii", _decode_errors="ignore", _out=sys.stdout, _tee=True) + self.assertEqual(p, "test") + def test_signal_exception(self): from sh import SignalException_15