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 stevedore==1.28.0
testtools==2.3.0 testtools==2.3.0
traceback2==1.4.0 traceback2==1.4.0
unittest2==1.1.0
urllib3==1.22 urllib3==1.22
voluptuous==0.11.1 voluptuous==0.11.1
wrapt==1.10.11 wrapt==1.10.11

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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