Skip to content

Commit

Permalink
Add a test case for ignoring decode errors with fd/file_chunk_consumer
Browse files Browse the repository at this point in the history
Also added some latin-1 encoded bytes to make it always invalid for
sys.stdout too.
  • Loading branch information
felixonmars committed Oct 19, 2022
1 parent 5c7a65e commit bccde9a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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

Expand Down

0 comments on commit bccde9a

Please sign in to comment.