summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-12-15 14:42:24 +0000
committerGerrit Code Review <review@openstack.org>2022-12-15 14:42:24 +0000
commitc35588d09b0a55f6431e6636e2cf2c6cef68f22b (patch)
tree166f0be1a11a4778a411b97afa0d0ad55e63e459
parentd95e83affe84bc82282cc54cb90653f952822b79 (diff)
parent1d8a06da78ed16ed29cdc3b153d67ec1961b57bf (diff)
downloadpython-novaclient-c35588d09b0a55f6431e6636e2cf2c6cef68f22b.tar.gz
Merge "tests: Fix Python 3.11 compatibility"
-rw-r--r--novaclient/tests/unit/test_shell.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/novaclient/tests/unit/test_shell.py b/novaclient/tests/unit/test_shell.py
index a997b23f..f46d0ad6 100644
--- a/novaclient/tests/unit/test_shell.py
+++ b/novaclient/tests/unit/test_shell.py
@@ -777,6 +777,8 @@ class ShellTest(utils.TestCase):
class TestLoadVersionedActions(utils.TestCase):
def test_load_versioned_actions(self):
+ # first load with API version 2.15, ensuring we use the 2.15 version of
+ # the underlying function (which returns 1)
parser = novaclient.shell.NovaClientArgumentParser()
subparsers = parser.add_subparsers(metavar='<subcommand>')
shell = novaclient.shell.OpenStackComputeShell()
@@ -787,6 +789,12 @@ class TestLoadVersionedActions(utils.TestCase):
self.assertEqual(
1, shell.subcommands['fake-action'].get_default('func')())
+ # now load with API version 2.25, ensuring we now use the
+ # correspponding version of the underlying function (which now returns
+ # 2)
+ parser = novaclient.shell.NovaClientArgumentParser()
+ subparsers = parser.add_subparsers(metavar='<subcommand>')
+ shell = novaclient.shell.OpenStackComputeShell()
shell.subcommands = {}
shell._find_actions(subparsers, fake_actions_module,
api_versions.APIVersion("2.25"), False)
@@ -794,10 +802,6 @@ class TestLoadVersionedActions(utils.TestCase):
self.assertEqual(
2, shell.subcommands['fake-action'].get_default('func')())
- self.assertIn('fake-action2', shell.subcommands.keys())
- self.assertEqual(
- 3, shell.subcommands['fake-action2'].get_default('func')())
-
def test_load_versioned_actions_not_in_version_range(self):
parser = novaclient.shell.NovaClientArgumentParser()
subparsers = parser.add_subparsers(metavar='<subcommand>')
@@ -908,6 +912,10 @@ class TestLoadVersionedActions(utils.TestCase):
mock_add_arg.reset_mock()
+ parser = novaclient.shell.NovaClientArgumentParser(add_help=False)
+ subparsers = parser.add_subparsers(metavar='<subcommand>')
+ shell = novaclient.shell.OpenStackComputeShell()
+ shell.subcommands = {}
shell._find_actions(subparsers, fake_actions_module,
api_versions.APIVersion("2.21"), False)
self.assertNotIn(mock.call('--foo', help="first foo"),