Skip to content

Commit 2954120

Browse files
committed
mapreduce/multiproc| Puts bad unicode excpetion handling under test
1 parent 4cbdcb1 commit 2954120

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/unittest_checker_similar.py

+26
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,29 @@ def test_get_map_data():
511511
lines = [line for idx, line in lineset.enumerate_stripped()]
512512
assert lines_expected == lines
513513
assert str(expected_lineset) == str(lineset)
514+
515+
516+
def test_ammend_stream_bad_unicode():
517+
""" Tests that ammend_stream() handles bad unicode errors """
518+
sim = similar.SimilarChecker()
519+
520+
class CustomException(Exception):
521+
pass
522+
523+
class MimicOtherReadError:
524+
def readlines(self, *args, **kwargs):
525+
raise CustomException()
526+
527+
raised = False
528+
try:
529+
sim.append_stream("--unimportant-name--", MimicOtherReadError())
530+
except CustomException:
531+
raised = True
532+
assert raised
533+
534+
class MimicBadUnicode:
535+
def readlines(self, *args, **kwargs):
536+
raise UnicodeDecodeError("a", b"a", 0, 0, "a")
537+
538+
sim.append_stream("--unimportant-name--", MimicBadUnicode())
539+
# nothing should happen that stops us getting here and beyond

0 commit comments

Comments
 (0)