Drop use of unittest2

unittest2 was needed for Python version <= 2.6, so it hasn't been needed
for quite some time. See unittest2 note one:

https://docs.python.org/2.7/library/unittest.html

This drops unittest2 in favor of the standard unittest module.

Change-Id: I2e787cfbf1709b7f9c889230a10c03689e032957
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-01-12 03:10:25 -06:00
parent a4f1078864
commit 5b26b749b5
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
18 changed files with 47 additions and 49 deletions

View File

@ -85,7 +85,6 @@ stestr==2.0.0
stevedore==1.28.0
testtools==2.3.0
traceback2==1.4.0
unittest2==1.1.0
urllib3==1.22
voluptuous==0.11.1
wrapt==1.10.11

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import unittest
import traceback
import test.functional as tf
from test.functional.s3api.s3_test_client import (
@ -28,7 +28,7 @@ def tearDownModule():
tf.teardown_package()
class S3ApiBase(unittest2.TestCase):
class S3ApiBase(unittest.TestCase):
def __init__(self, method_name):
super(S3ApiBase, self).__init__(method_name)
self.method_name = method_name

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import unittest
import os
import test.functional as tf
from swift.common.middleware.s3api.etree import fromstring
@ -155,4 +155,4 @@ class TestS3AclSigV4(TestS3Acl):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -15,7 +15,7 @@
import botocore
import datetime
import unittest2
import unittest
import os
import test.functional as tf
@ -472,4 +472,4 @@ class TestS3ApiBucketSigV4(TestS3ApiBucket):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import unittest
import os
import test.functional as tf
from swift.common.middleware.s3api.etree import fromstring, tostring, Element, \
@ -240,4 +240,4 @@ class TestS3ApiMultiDeleteSigV4(TestS3ApiMultiDelete):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -15,7 +15,7 @@
import base64
import binascii
import unittest2
import unittest
import os
import boto
@ -971,4 +971,4 @@ class TestS3ApiMultiUploadSigV4(TestS3ApiMultiUpload):
self.assertEqual(status, 204) # sanity
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import unittest
import os
import boto
@ -873,35 +873,35 @@ class TestS3ApiObjectSigV4(TestS3ApiObject):
def setUp(self):
super(TestS3ApiObjectSigV4, self).setUp()
@unittest2.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
@unittest.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
def test_put_object_metadata(self):
super(TestS3ApiObjectSigV4, self).test_put_object_metadata()
@unittest2.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
@unittest.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
def test_put_object_copy_source_if_modified_since(self):
super(TestS3ApiObjectSigV4, self).\
test_put_object_copy_source_if_modified_since()
@unittest2.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
@unittest.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
def test_put_object_copy_source_if_unmodified_since(self):
super(TestS3ApiObjectSigV4, self).\
test_put_object_copy_source_if_unmodified_since()
@unittest2.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
@unittest.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
def test_put_object_copy_source_if_match(self):
super(TestS3ApiObjectSigV4,
self).test_put_object_copy_source_if_match()
@unittest2.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
@unittest.skipIf(StrictVersion(boto.__version__) < StrictVersion('3.0'),
'This stuff got the signing issue of boto<=2.x')
def test_put_object_copy_source_if_none_match(self):
super(TestS3ApiObjectSigV4,
self).test_put_object_copy_source_if_none_match()
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import unittest
import os
import test.functional as tf
@ -97,4 +97,4 @@ class TestS3ApiServiceSigV4(TestS3ApiService):
super(TestS3ApiServiceSigV4, self).setUp()
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -22,7 +22,7 @@ import sys
import socket
import time
from unittest2 import SkipTest
from unittest import SkipTest
from xml.dom import minidom
import six

View File

@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import unittest
import json
from uuid import uuid4
from string import ascii_letters
@ -38,7 +38,7 @@ def tearDownModule():
tf.teardown_package()
class TestAccount(unittest2.TestCase):
class TestAccount(unittest.TestCase):
existing_metadata = None
@classmethod
@ -888,7 +888,7 @@ class TestAccount(unittest2.TestCase):
self.assertEqual(resp.status, 400)
class TestAccountInNonDefaultDomain(unittest2.TestCase):
class TestAccountInNonDefaultDomain(unittest.TestCase):
def setUp(self):
if tf.skip or tf.skip2 or tf.skip_if_not_v3:
raise SkipTest('AUTH VERSION 3 SPECIFIC TEST')
@ -917,4 +917,4 @@ class TestAccountInNonDefaultDomain(unittest2.TestCase):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -16,7 +16,7 @@
# limitations under the License.
import json
import unittest2
import unittest
from uuid import uuid4
from test.functional import check_response, cluster_info, retry, \
@ -35,7 +35,7 @@ def tearDownModule():
tf.teardown_package()
class TestContainer(unittest2.TestCase):
class TestContainer(unittest.TestCase):
def setUp(self):
if tf.skip:
@ -1652,7 +1652,7 @@ class TestContainer(unittest2.TestCase):
self.assertEqual(body, b'0123456789')
class BaseTestContainerACLs(unittest2.TestCase):
class BaseTestContainerACLs(unittest.TestCase):
# subclasses can change the account in which container
# is created/deleted by setUp/tearDown
account = 1
@ -1827,4 +1827,4 @@ class TestContainerACLsAccount4(BaseTestContainerACLs):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest2 import SkipTest
from unittest import SkipTest
import six
import test.functional as tf

View File

@ -17,7 +17,7 @@
import datetime
import json
import unittest2
import unittest
from uuid import uuid4
import time
from xml.dom import minidom
@ -38,7 +38,7 @@ def tearDownModule():
tf.teardown_package()
class TestObject(unittest2.TestCase):
class TestObject(unittest.TestCase):
def setUp(self):
if tf.skip or tf.skip2:
@ -1698,4 +1698,4 @@ class TestObject(unittest2.TestCase):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -16,7 +16,7 @@
import functools
import six
from unittest2 import SkipTest
from unittest import SkipTest
from six.moves.urllib.parse import unquote
from swift.common.utils import quote
import test.functional as tf

View File

@ -15,7 +15,7 @@
# limitations under the License.
import hmac
import unittest2
import unittest
import itertools
import hashlib
import six
@ -2452,4 +2452,4 @@ class TestSymlinkContainerTempurl(Base):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -17,7 +17,7 @@
from copy import deepcopy
import json
import time
import unittest2
import unittest
import six
from six.moves.urllib.parse import quote, unquote
@ -968,7 +968,7 @@ class TestObjectVersioningHistoryModeUTF8(
pass
class TestSloWithVersioning(unittest2.TestCase):
class TestSloWithVersioning(unittest.TestCase):
def setUp(self):
if 'slo' not in cluster_info:

View File

@ -22,7 +22,7 @@ import random
import six
from six.moves import urllib
import time
import unittest2
import unittest
import uuid
from copy import deepcopy
import eventlet
@ -93,7 +93,7 @@ class BaseEnv(object):
pass
class Base(unittest2.TestCase):
class Base(unittest.TestCase):
env = BaseEnv
@classmethod
@ -2854,7 +2854,7 @@ class TestFileComparisonUTF8(Base2, TestFileComparison):
pass
class TestServiceToken(unittest2.TestCase):
class TestServiceToken(unittest.TestCase):
def setUp(self):
if tf.skip_service_tokens:
@ -3025,4 +3025,4 @@ class TestServiceToken(unittest2.TestCase):
if __name__ == '__main__':
unittest2.main()
unittest.main()

View File

@ -59,10 +59,9 @@ from gzip import GzipFile
import mock as mocklib
import inspect
import unittest
import unittest2
class SkipTest(unittest2.SkipTest, unittest.SkipTest):
class SkipTest(unittest.SkipTest):
pass
EMPTY_ETAG = md5().hexdigest()