From e0f0065e178a4b823fd14a018fad5ca7c5d2db84 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 26 Dec 2020 02:02:07 -0600 Subject: [PATCH] Replace six.b with b prefix for bytes literals --- tests/test_streaming.py | 7 +++---- tweepy/streaming.py | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 349051d..3b0a261 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -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()) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 8a41a3f..1384668 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -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] -- 2.25.1