Python3.11: fix crashes in ShellTest

In Python3.11, global flags must be placed right at the start of a
regular expression.

The following regex:

	r'.*?(?m)^Lists all volumes.',
must become:

        r'(?m).*?^Lists all volumes.',

However, since we are using re.MULTILINE, we actually do not need to use
a global flag.

This commit fixes the following tests in Python3.11:
- cinderclient.tests.unit.test_shell.ShellTest.test_help_arg_no_subcommand
- cinderclient.tests.unit.test_shell.ShellTest.test_help
- cinderclient.tests.unit.test_shell.ShellTest.test_help_on_subcommand
- cinderclient.tests.unit.test_shell.ShellTest.test_help_on_subcommand_mv

Closes-Bug: #1983047
Change-Id: If20abef109ddd7107c83b5886beb666a6550a640
This commit is contained in:
Cyril Roelandt 2022-07-28 20:14:36 +02:00 committed by Brian Rosmaita
parent 9a4a7868b8
commit 20506ef3a8
1 changed files with 8 additions and 8 deletions

View File

@ -120,9 +120,9 @@ class ShellTest(utils.TestCase):
# Some expected help output, including microversioned commands
required = [
r'.*?^usage: ',
r'.*?(?m)^\s+create\s+Creates a volume.',
r'.*?(?m)^\s+summary\s+Get volumes summary.',
r'.*?(?m)^Run "cinder help SUBCOMMAND" for help on a subcommand.',
r'.*?^\s+create\s+Creates a volume.',
r'.*?^\s+summary\s+Get volumes summary.',
r'.*?^Run "cinder help SUBCOMMAND" for help on a subcommand.',
]
help_text = self.shell('help')
for r in required:
@ -132,7 +132,7 @@ class ShellTest(utils.TestCase):
def test_help_on_subcommand(self):
required = [
r'.*?^usage: cinder list',
r'.*?(?m)^Lists all volumes.',
r'.*?^Lists all volumes.',
]
help_text = self.shell('help list')
for r in required:
@ -142,7 +142,7 @@ class ShellTest(utils.TestCase):
def test_help_on_subcommand_mv(self):
required = [
r'.*?^usage: cinder summary',
r'.*?(?m)^Get volumes summary.',
r'.*?^Get volumes summary.',
]
help_text = self.shell('help summary')
for r in required:
@ -152,9 +152,9 @@ class ShellTest(utils.TestCase):
def test_help_arg_no_subcommand(self):
required = [
r'.*?^usage: ',
r'.*?(?m)^\s+create\s+Creates a volume.',
r'.*?(?m)^\s+summary\s+Get volumes summary.',
r'.*?(?m)^Run "cinder help SUBCOMMAND" for help on a subcommand.',
r'.*?^\s+create\s+Creates a volume.',
r'.*?^\s+summary\s+Get volumes summary.',
r'.*?^Run "cinder help SUBCOMMAND" for help on a subcommand.',
]
help_text = self.shell('--os-volume-api-version 3.40')
for r in required: