Replace six.b with b prefix for bytes literals
authorHarmon <Harmon758@gmail.com>
Sat, 26 Dec 2020 08:02:07 +0000 (02:02 -0600)
committerHarmon <Harmon758@gmail.com>
Sat, 26 Dec 2020 08:02:07 +0000 (02:02 -0600)
tests/test_streaming.py
tweepy/streaming.py

index 349051d75b8eba1d96f5c9b4e33bc1555aad7d24..3b0a2615a6e108b032197f310fe5512de9c55c58 100644 (file)
@@ -3,7 +3,6 @@ import unittest
 from unittest.case import skip
 
 from mock import MagicMock, patch
-import six
 
 from .config import create_auth
 from .test_utils import mock_tweet
@@ -109,7 +108,7 @@ class TweepyStreamTests(unittest.TestCase):
 
 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]:
@@ -144,7 +143,7 @@ class TweepyStreamReadBufferTests(unittest.TestCase):
             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)
@@ -163,7 +162,7 @@ class TweepyStreamReadBufferTests(unittest.TestCase):
         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())
index 8a41a3f08ca8ccccc809cc4265a7fce9b31bf136..1384668e93f332c18ecdd4b949c1c30c38be4c7f 100644 (file)
@@ -169,7 +169,7 @@ class ReadBuffer(object):
 
     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
 
@@ -179,9 +179,9 @@ class ReadBuffer(object):
                 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,
@@ -196,7 +196,7 @@ class ReadBuffer(object):
             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]