Skip to content

Commit

Permalink
mapreduce/multiproc| Puts bad unicode excpetion handling under test
Browse files Browse the repository at this point in the history
  • Loading branch information
doublethefish committed Mar 31, 2020
1 parent 4eadea3 commit 9b71535
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/unittest_checker_similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,29 @@ def test_get_map_data():
# There doesn't seem to be a faster way of doing this, yet.
lines = (line for idx, line in lineset_obj.enumerate_stripped())
assert tuple(expected_lines) == tuple(lines)


def test_ammend_stream_bad_unicode():
""" Tests that ammend_stream() handles bad unicode errors """
sim = similar.SimilarChecker()

class CustomException(Exception):
pass

class MimicOtherReadError:
def readlines(self, *args, **kwargs): # pylint: disable=no-self-use
raise CustomException()

raised = False
try:
sim.append_stream("--unimportant-name--", MimicOtherReadError())
except CustomException:
raised = True
assert raised

class MimicBadUnicode:
def readlines(self, *args, **kwargs): # pylint: disable=no-self-use
raise UnicodeDecodeError("a", b"a", 0, 0, "a")

sim.append_stream("--unimportant-name--", MimicBadUnicode())
# nothing should happen that stops us getting here and beyond

0 comments on commit 9b71535

Please sign in to comment.