Remove usage of six

Change-Id: Ifce6c18e1da1bb3eb0cff9f03a91cdd1a84dea4c
Co-authored-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
songwenping 2022-04-22 15:43:49 +08:00 committed by Stephen Finucane
parent 49948dfad1
commit a814032763
7 changed files with 8 additions and 54 deletions

View File

@ -1,16 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
six.add_move(six.MovedModule('mock', 'mock', 'unittest.mock'))

View File

@ -14,7 +14,6 @@ import os
import tempfile
import fixtures
import six
class CreateFileWithContent(fixtures.Fixture):
@ -56,7 +55,7 @@ class CreateFileWithContent(fixtures.Fixture):
def setUp(self):
super(CreateFileWithContent, self).setUp()
contents = self._contents
if isinstance(contents, six.text_type):
if isinstance(contents, str):
contents = contents.encode(self._encoding)
if not os.path.isabs(self._filename):
(fd, self.path) = tempfile.mkstemp(prefix=self._filename,

View File

@ -1,16 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
six.add_move(six.MovedModule('mock', 'mock', 'unittest.mock'))

View File

@ -20,7 +20,6 @@ import unittest
from unittest import mock
import fixtures
import six
import testtools
from oslotest import base
@ -142,7 +141,7 @@ class TestTempFiles(base.BaseTestCase):
self.assertEqual(1, len(temps))
with open(temps[0], 'rb') as f:
contents = f.read()
self.assertEqual('ಠ_ಠ', six.text_type(contents, encoding='utf-8'))
self.assertEqual('ಠ_ಠ', str(contents, encoding='utf-8'))
def test_create_unicode_files_encoding(self):
files = [["embarrassed", '⊙﹏⊙', 'utf-8']]
@ -150,7 +149,7 @@ class TestTempFiles(base.BaseTestCase):
self.assertEqual(1, len(temps))
with open(temps[0], 'rb') as f:
contents = f.read()
self.assertEqual('⊙﹏⊙', six.text_type(contents, encoding='utf-8'))
self.assertEqual('⊙﹏⊙', str(contents, encoding='utf-8'))
def test_create_unicode_files_multi_encoding(self):
files = [
@ -162,10 +161,9 @@ class TestTempFiles(base.BaseTestCase):
for i, (basename, raw_contents, raw_encoding) in enumerate(files):
with open(temps[i], 'rb') as f:
contents = f.read()
if not isinstance(raw_contents, six.text_type):
raw_contents = six.text_type(raw_contents,
encoding=raw_encoding)
self.assertEqual(six.text_type(contents, encoding=raw_encoding),
if not isinstance(raw_contents, str):
raw_contents = str(raw_contents, encoding=raw_encoding)
self.assertEqual(str(contents, encoding=raw_encoding),
raw_contents)
def test_create_bad_encoding(self):

View File

@ -16,8 +16,6 @@
import os
import six
from oslotest import base
from oslotest import createfile
@ -32,7 +30,7 @@ class CreateFileWithContentTest(base.BaseTestCase):
f.setUp()
with open(f.path, 'rb') as f:
contents = f.read()
self.assertEqual('ಠ_ಠ', six.text_type(contents, encoding='utf-8'))
self.assertEqual('ಠ_ಠ', str(contents, encoding='utf-8'))
def test_create_unicode_files_encoding(self):
f = createfile.CreateFileWithContent(
@ -41,7 +39,7 @@ class CreateFileWithContentTest(base.BaseTestCase):
f.setUp()
with open(f.path, 'rb') as f:
contents = f.read()
self.assertEqual('⊙﹏⊙', six.text_type(contents, encoding='utf-8'))
self.assertEqual('⊙﹏⊙', str(contents, encoding='utf-8'))
def test_create_bad_encoding(self):
f = createfile.CreateFileWithContent(

View File

@ -1,8 +1,3 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
fixtures>=3.0.0 # Apache-2.0/BSD
python-subunit>=1.0.0 # Apache-2.0/BSD
six>=1.10.0 # MIT
testtools>=2.2.0 # MIT

View File

@ -41,7 +41,3 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen
[flake8]
show-source = true
exclude = .tox,dist,doc,*.egg,build
[hacking]
import_exceptions =
six.moves.mock