diff --git a/kazoo/protocol/connection.py b/kazoo/protocol/connection.py index d12d6eba..3df7b162 100644 --- a/kazoo/protocol/connection.py +++ b/kazoo/protocol/connection.py @@ -7,7 +7,6 @@ import select import socket import ssl -import sys import time from kazoo.exceptions import ( @@ -75,16 +74,10 @@ CLOSE_RESPONSE = Close.type -if sys.version_info > (3,): # pragma: nocover - def buffer(obj, offset=0): - return memoryview(obj)[offset:] - - advance_iterator = next -else: # pragma: nocover - - def advance_iterator(it): - return it.next() +# removed from Python3+ +def buffer(obj, offset=0): + return memoryview(obj)[offset:] class RWPinger(object): @@ -526,7 +519,7 @@ def _send_ping(self, connect_timeout): # Determine if we need to check for a r/w server if self._ro_mode: - result = advance_iterator(self._ro_mode) + result = next(self._ro_mode) if result: self._rw_server = result raise RWServerAvailable() diff --git a/kazoo/tests/test_client.py b/kazoo/tests/test_client.py index e376baaf..3f1748c4 100644 --- a/kazoo/tests/test_client.py +++ b/kazoo/tests/test_client.py @@ -1,6 +1,5 @@ import os import socket -import sys import tempfile import threading import time @@ -30,17 +29,6 @@ from kazoo.tests.util import CI_ZK_VERSION -if sys.version_info > (3,): # pragma: nocover - - def u(s): - return s - -else: # pragma: nocover - - def u(s): - return unicode(s, "unicode_escape") # noqa - - class TestClientTransitions(KazooTestCase): @staticmethod def make_event(): @@ -197,8 +185,8 @@ def test_connect_auth(self): client.close() def test_unicode_auth(self): - username = u(r"xe4/\hm") - password = u(r"/\xe4hm") + username = r"xe4/\hm" + password = r"/\xe4hm" digest_auth = "%s:%s" % (username, password) acl = self._makeAuth(username, password, all=True) @@ -543,10 +531,10 @@ def test_create_empty_string(self): def test_create_unicode_path(self): client = self.client - path = client.create(u("/ascii")) - assert path == u("/ascii") - path = client.create(u("/\xe4hm")) - assert path == u("/\xe4hm") + path = client.create("/ascii") + assert path == "/ascii" + path = client.create("/\xe4hm") + assert path == "/\xe4hm" def test_create_async_returns_unchrooted_path(self): client = self.client @@ -593,7 +581,7 @@ def test_create_value(self): def test_create_unicode_value(self): client = self.client with pytest.raises(TypeError): - client.create("/1", u("\xe4hm")) + client.create("/1", "\xe4hm") def test_create_large_value(self): client = self.client diff --git a/kazoo/tests/test_paths.py b/kazoo/tests/test_paths.py index 2749634e..438c2eca 100644 --- a/kazoo/tests/test_paths.py +++ b/kazoo/tests/test_paths.py @@ -1,4 +1,3 @@ -import sys from unittest import TestCase import pytest @@ -6,17 +5,6 @@ from kazoo.protocol import paths -if sys.version_info > (3,): # pragma: nocover - - def u(s): - return s - -else: # pragma: nocover - - def u(s): - return unicode(s, "unicode_escape") # noqa - - class NormPathTestCase(TestCase): def test_normpath(self): assert paths.normpath("/a/b") == "/a/b" @@ -25,7 +13,7 @@ def test_normpath_empty(self): assert paths.normpath("") == "" def test_normpath_unicode(self): - assert paths.normpath(u("/\xe4/b")) == u("/\xe4/b") + assert paths.normpath("/\xe4/b") == "/\xe4/b" def test_normpath_dots(self): assert paths.normpath("/a./b../c") == "/a./b../c"