Merge "[Part5] Remove six"

This commit is contained in:
Zuul 2021-09-15 02:13:34 +00:00 committed by Gerrit Code Review
commit dac4066c95
5 changed files with 8 additions and 21 deletions

View File

@ -22,7 +22,6 @@ import uuid
from oslo_utils import timeutils
from pymongo import cursor
import pymongo.errors
import six
from testtools import matchers
from zaqar.common import cache as oslo_cache
@ -273,7 +272,7 @@ class MongodbQueueTests(MongodbSetupMixin, base.QueueControllerTest):
def test_raises_connection_error(self):
with mock.patch.object(cursor.Cursor,
'next' if six.PY2 else '__next__',
'__next__',
spec=True) as method:
error = pymongo.errors.ConnectionFailure()
method.side_effect = error

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
import uuid
from zaqar import storage
@ -76,10 +75,7 @@ class SqlalchemyFlavorsTest1(DBCreateMixin, base.FlavorsControllerTest1):
class MsgidTests(testing.TestBase):
def test_encode(self):
if six.PY2:
ids = [3, long(1), 0] # noqa
elif six.PY3:
ids = [3, 1, 0]
ids = [3, 1, 0]
msgids = ['5c693a50', '5c693a52', '5c693a53']
for msgid, id in zip(msgids, ids):
self.assertEqual(msgid, utils.msgid_encode(id))

View File

@ -20,7 +20,6 @@ from unittest import mock
import ddt
from oslo_utils import timeutils
from oslo_utils import uuidutils
import six
from testtools import matchers
from zaqar.common import consts
@ -242,9 +241,6 @@ class MessagesBaseTest(base.V2Base):
def test_post_to_non_ascii_queue(self):
queue_name = u'non-ascii-n\u0153me'
if six.PY2:
queue_name = queue_name.encode('utf-8')
resp = self._post_messages(queue_name)
self.assertEqual(400, resp['headers']['status'])

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
import falcon
from falcon import testing as ftest
from oslo_serialization import jsonutils
@ -93,8 +91,7 @@ class TestBase(testing.TestBase):
kwargs.pop('need_project_id', None)
kwargs['headers'] = headers
try:
if six.PY3:
path.encode('latin1').decode('utf-8', 'replace')
path.encode('latin1').decode('utf-8', 'replace')
except UnicodeEncodeError:
self.srmock.status = falcon.HTTP_400
return

View File

@ -16,7 +16,6 @@ import io
import json
import falcon
import six
import testtools
from zaqar.transport.wsgi import utils
@ -114,7 +113,7 @@ class TestUtils(testtools.TestCase):
def test_no_spec(self):
obj = {u'body': {'event': 'start_backup'}, 'ttl': 300}
document = six.text_type(json.dumps(obj, ensure_ascii=False))
document = str(json.dumps(obj, ensure_ascii=False))
doc_stream = io.StringIO(document)
deserialized = utils.deserialize(doc_stream, len(document))
@ -127,7 +126,7 @@ class TestUtils(testtools.TestCase):
def test_no_spec_array(self):
things = [{u'body': {'event': 'start_backup'}, 'ttl': 300}]
document = six.text_type(json.dumps(things, ensure_ascii=False))
document = str(json.dumps(things, ensure_ascii=False))
doc_stream = io.StringIO(document)
deserialized = utils.deserialize(doc_stream, len(document))
@ -146,9 +145,9 @@ class TestUtils(testtools.TestCase):
def test_deserialize_and_sanitize_json_obj(self):
obj = {u'body': {'event': 'start_backup'}, 'id': 'DEADBEEF'}
document = six.text_type(json.dumps(obj, ensure_ascii=False))
document = str(json.dumps(obj, ensure_ascii=False))
stream = io.StringIO(document)
spec = [('body', dict, None), ('id', six.string_types, None)]
spec = [('body', dict, None), ('id', str, None)]
# Positive test
deserialized_object = utils.deserialize(stream, len(document))
@ -163,7 +162,7 @@ class TestUtils(testtools.TestCase):
def test_deserialize_and_sanitize_json_array(self):
array = [{u'body': {u'x': 1}}, {u'body': {u'x': 2}}]
document = six.text_type(json.dumps(array, ensure_ascii=False))
document = str(json.dumps(array, ensure_ascii=False))
stream = io.StringIO(document)
spec = [('body', dict, None)]