From 18543648a6f6c75a3d20415cdfa51aeca52f752f Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Thu, 21 Dec 2017 11:06:13 +0100 Subject: Adjust streaming tests --- mastodon/streaming.py | 2 +- tests/test_streaming.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mastodon/streaming.py b/mastodon/streaming.py index 3df3298..4941ace 100644 --- a/mastodon/streaming.py +++ b/mastodon/streaming.py @@ -56,7 +56,7 @@ class StreamListener(object): line = raw_line.decode('utf-8') except UnicodeDecodeError as err: six.raise_from( - MastodonMalformedEventError("Malformed UTF-8", line), + MastodonMalformedEventError("Malformed UTF-8"), err ) diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 33a3f9a..ac8e691 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -30,7 +30,18 @@ class Listener(StreamListener): def handle_stream_(self, lines): """Test helper to avoid littering all tests with six.b().""" - return self.handle_stream(map(six.b, lines)) + class MockResponse(): + def __init__(self, data): + self.data = data + + def iter_content(self, chunk_size): + for line in self.data: + for byte in line: + bytearr = bytearray() + bytearr.append(byte) + yield(bytearr) + yield(b'\n') + return self.handle_stream(MockResponse(map(six.b, lines))) def test_heartbeat(): -- cgit v1.2.3