from unittest.case import skip
from mock import MagicMock, patch
-import six
from .config import create_auth
from .test_utils import mock_tweet
class TweepyStreamReadBufferTests(unittest.TestCase):
- stream = six.b("""11\n{id:12345}\n\n24\n{id:23456, test:"blah"}\n""")
+ stream = b"""11\n{id:12345}\n\n24\n{id:23456, test:"blah"}\n"""
def test_read_tweet(self):
for length in [1, 2, 5, 10, 20, 50]:
return ""
# Create a fake stream
- stream = io.BytesIO(six.b(''))
+ stream = io.BytesIO(b'')
# Mock it's read function so it can't be called too many times
mock_read = MagicMock(side_effect=on_read)
self.assertEqual(mock_read.call_count, 0)
def test_read_unicode_tweet(self):
- stream = six.b('11\n{id:12345}\n\n23\n{id:23456, test:"\xe3\x81\x93"}\n\n')
+ stream = b'11\n{id:12345}\n\n23\n{id:23456, test:"\xe3\x81\x93"}\n\n'
for length in [1, 2, 5, 10, 20, 50]:
buf = ReadBuffer(io.BytesIO(stream), length)
self.assertEqual('11\n', buf.read_line())
def __init__(self, stream, chunk_size, encoding='utf-8'):
self._stream = stream
- self._buffer = six.b('')
+ self._buffer = b''
self._chunk_size = chunk_size
self._encoding = encoding
return self._pop(length)
read_len = max(self._chunk_size, length - len(self._buffer))
self._buffer += self._stream.read(read_len)
- return six.b('')
+ return b''
- def read_line(self, sep=six.b('\n')):
+ def read_line(self, sep=b'\n'):
"""Read the data stream until a given separator is found (default \n)
:param sep: Separator to read until. Must by of the bytes type (str in python 2,
else:
start = len(self._buffer)
self._buffer += self._stream.read(self._chunk_size)
- return six.b('')
+ return b''
def _pop(self, length):
r = self._buffer[:length]