aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2017-12-21 11:06:13 +0100
committerLorenz Diener <[email protected]>2017-12-21 11:06:13 +0100
commit18543648a6f6c75a3d20415cdfa51aeca52f752f (patch)
tree72afaa1c6c2d3e10fb454c71b753807c75448cb1
parent08a0e5ff67600a7f12cd91daf25217ba3e8e51d3 (diff)
downloadmastodon.py-18543648a6f6c75a3d20415cdfa51aeca52f752f.tar.gz
Adjust streaming tests
-rw-r--r--mastodon/streaming.py2
-rw-r--r--tests/test_streaming.py13
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):
56 line = raw_line.decode('utf-8') 56 line = raw_line.decode('utf-8')
57 except UnicodeDecodeError as err: 57 except UnicodeDecodeError as err:
58 six.raise_from( 58 six.raise_from(
59 MastodonMalformedEventError("Malformed UTF-8", line), 59 MastodonMalformedEventError("Malformed UTF-8"),
60 err 60 err
61 ) 61 )
62 62
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):
30 30
31 def handle_stream_(self, lines): 31 def handle_stream_(self, lines):
32 """Test helper to avoid littering all tests with six.b().""" 32 """Test helper to avoid littering all tests with six.b()."""
33 return self.handle_stream(map(six.b, lines)) 33 class MockResponse():
34 def __init__(self, data):
35 self.data = data
36
37 def iter_content(self, chunk_size):
38 for line in self.data:
39 for byte in line:
40 bytearr = bytearray()
41 bytearr.append(byte)
42 yield(bytearr)
43 yield(b'\n')
44 return self.handle_stream(MockResponse(map(six.b, lines)))
34 45
35 46
36def test_heartbeat(): 47def test_heartbeat():
Powered by cgit v1.2.3 (git 2.41.0)