From 2f55c3ae2e42746f5d0db225686ccb18f7923ae1 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sun, 12 Jan 2020 02:48:30 -0600 Subject: [PATCH] Drop use of unittest2 unittest2 was needed for Python versions <= 2.6, so it has not been needed for quite awhile (ever in this project). See unittest2 note on: https://docs.python.org/2.7/library/unittest.html This drops unittest2 in favor of the standard unittest module. Change-Id: I21264290d783d582dfb886b799781380dbf5757d Signed-off-by: Sean McGinnis --- cinderlib/tests/functional/base_tests.py | 4 ++-- cinderlib/tests/functional/test_basic.py | 2 +- cinderlib/tests/unit/base.py | 4 ++-- cinderlib/tests/unit/persistence/base.py | 12 ++++++------ doc/source/validating.rst | 4 ++-- lower-constraints.txt | 1 - 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cinderlib/tests/functional/base_tests.py b/cinderlib/tests/functional/base_tests.py index dfb88a1..91d11a4 100644 --- a/cinderlib/tests/functional/base_tests.py +++ b/cinderlib/tests/functional/base_tests.py @@ -17,11 +17,11 @@ import functools import os import subprocess import tempfile +import unittest from oslo_config import cfg from oslo_utils import strutils import six -import unittest2 import yaml import cinderlib @@ -57,7 +57,7 @@ def get_bool_env(param_string, default=False): return strutils.bool_from_string(param, strict=True) -class BaseFunctTestCase(unittest2.TestCase): +class BaseFunctTestCase(unittest.TestCase): FNULL = open(os.devnull, 'w') CONFIG_FILE = os.environ.get('CL_FTEST_CFG', '/etc/cinder/cinder.conf') PRECISION = os.environ.get('CL_FTEST_PRECISION', 0) diff --git a/cinderlib/tests/functional/test_basic.py b/cinderlib/tests/functional/test_basic.py index b8ccc09..b5ee2c4 100644 --- a/cinderlib/tests/functional/test_basic.py +++ b/cinderlib/tests/functional/test_basic.py @@ -20,7 +20,7 @@ import cinderlib from cinderlib.tests.functional import base_tests -class BaseFunctTestCase(base_tests.unittest2.TestCase): +class BaseFunctTestCase(base_tests.unittest.TestCase): def test_list_supported_drivers(self): expected_keys = {'version', 'class_name', 'supported', 'ci_wiki_name', 'driver_options', 'class_fqn', 'desc'} diff --git a/cinderlib/tests/unit/base.py b/cinderlib/tests/unit/base.py index 41f60ba..28aa9a1 100644 --- a/cinderlib/tests/unit/base.py +++ b/cinderlib/tests/unit/base.py @@ -15,7 +15,7 @@ import mock -import unittest2 +import unittest from oslo_config import cfg import six @@ -38,7 +38,7 @@ _replace_oslo_cli_parse() cinderlib.setup(persistence_config={'storage': utils.get_mock_persistence()}) -class BaseTest(unittest2.TestCase): +class BaseTest(unittest.TestCase): PERSISTENCE_CFG = None def setUp(self): diff --git a/cinderlib/tests/unit/persistence/base.py b/cinderlib/tests/unit/persistence/base.py index c89aba1..17d95f6 100644 --- a/cinderlib/tests/unit/persistence/base.py +++ b/cinderlib/tests/unit/persistence/base.py @@ -386,7 +386,7 @@ class BasePersistenceTest(helper.TestHelper): @mock.patch('cinderlib.persistence.base.DB.volume_type_get') def test__volume_type_get_by_name(self, get_mock): # Only test when using our fake DB class. We cannot use - # unittest2.skipUnless because persistence is configure in setUpClass, + # unittest.skipUnless because persistence is configure in setUpClass, # which is called after the decorator. if not isinstance(cinderlib.objects.Backend.persistence.db, persistence_base.DB): @@ -414,7 +414,7 @@ class BasePersistenceTest(helper.TestHelper): def test_volume_get_all_by_host(self): # Only test when using our fake DB class. We cannot use - # unittest2.skipUnless because persistence is configure in setUpClass, + # unittest.skipUnless because persistence is configure in setUpClass, # which is called after the decorator. if not isinstance(cinderlib.objects.Backend.persistence.db, persistence_base.DB): @@ -442,7 +442,7 @@ class BasePersistenceTest(helper.TestHelper): def test__volume_admin_metadata_get(self): # Only test when using our fake DB class. We cannot use - # unittest2.skipUnless because persistence is configure in setUpClass, + # unittest.skipUnless because persistence is configure in setUpClass, # which is called after the decorator. if not isinstance(cinderlib.objects.Backend.persistence.db, persistence_base.DB): @@ -457,7 +457,7 @@ class BasePersistenceTest(helper.TestHelper): def test__volume_admin_metadata_update(self): # Only test when using our fake DB class. We cannot use - # unittest2.skipUnless because persistence is configure in setUpClass, + # unittest.skipUnless because persistence is configure in setUpClass, # which is called after the decorator. if not isinstance(cinderlib.objects.Backend.persistence.db, persistence_base.DB): @@ -480,7 +480,7 @@ class BasePersistenceTest(helper.TestHelper): def test__volume_admin_metadata_update_do_nothing(self): # Only test when using our fake DB class. We cannot use - # unittest2.skipUnless because persistence is configure in setUpClass, + # unittest.skipUnless because persistence is configure in setUpClass, # which is called after the decorator. if not isinstance(cinderlib.objects.Backend.persistence.db, persistence_base.DB): @@ -504,7 +504,7 @@ class BasePersistenceTest(helper.TestHelper): def test_volume_admin_metadata_delete(self): # Only test when using our fake DB class. We cannot use - # unittest2.skipUnless because persistence is configure in setUpClass, + # unittest.skipUnless because persistence is configure in setUpClass, # which is called after the decorator. if not isinstance(cinderlib.objects.Backend.persistence.db, persistence_base.DB): diff --git a/doc/source/validating.rst b/doc/source/validating.rst index 731e5cb..2b04b2e 100644 --- a/doc/source/validating.rst +++ b/doc/source/validating.rst @@ -131,7 +131,7 @@ run: .. code-block:: shell - $ python -m unittest2 discover -v cinderlib.tests.functional + $ python -m unittest discover -v cinderlib.tests.functional test_attach_detach_volume_on_lvmdriver-1 (cinderlib.tests.functional.test_basic.BackendFunctBasic) ... ok test_attach_detach_volume_via_attachment_on_lvmdriver-1 (cinderlib.tests.functional.test_basic.BackendFunctBasic) ... ok @@ -310,7 +310,7 @@ provides a custom configuration YAML file with the backend configuration:: For jobs in the *cinderlib* project you can use the ``openstack-tox-functional-with-sudo`` parent, but for jobs in the *Cinder* project you'll have to call this yourself by calling tox or using the same -command we used during our manual testing: ``python -m unittest2 discover -v +command we used during our manual testing: ``python -m unittest discover -v cinderlib.tests.functional``. Use existing job diff --git a/lower-constraints.txt b/lower-constraints.txt index 89ec574..473199a 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -13,5 +13,4 @@ Sphinx==1.6.2 sphixcontrib-websupport==1.0.1 stestr==1.0.0 stevedore==1.20.0 -unittest2==1.1.0 urllib3==1.21.1