magnumclient: add patch to fix tests with python 3.10

Change-Id: Ibafe2f9c77841966406515a9407a9c3233d52464
This commit is contained in:
Dirk Müller 2022-06-19 19:18:26 +02:00
parent 9bbdf64d5f
commit 6e707b4e81
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From 972aff0f329caf3343038349ebe86b5d039ca6ab Mon Sep 17 00:00:00 2001
From: Felipe Reyes <felipe.reyes@canonical.com>
Date: Fri, 25 Mar 2022 09:46:20 -0300
Subject: [PATCH] Fix test_help_on_subcommand on Python 3.10
Python 3.10 changed the way the optional arguments defined in argparse
are listed in the help output, the title was changed from "Optional
arguments" to "Options".
This checks the python version where the unit test is being executed and
uses the string that corresponds.
Story: 2009946
Task: 44858
Change-Id: Ibee09bf76399849f7da987c4661fa1945d27afb7
---
magnumclient/tests/test_shell.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/magnumclient/tests/test_shell.py b/magnumclient/tests/test_shell.py
index c4b8b8d..fb1d209 100644
--- a/magnumclient/tests/test_shell.py
+++ b/magnumclient/tests/test_shell.py
@@ -119,9 +119,13 @@ class ShellTest(utils.TestCase):
def test_help_on_subcommand(self):
required = [
'.*?^usage: magnum bay-create',
- '.*?^Create a bay.',
- '.*?^Optional arguments:',
+ '.*?^Create a bay.'
]
+ # https://bugs.python.org/issue9694
+ if sys.version_info[:2] >= (3, 10):
+ required.append('.*?^Options:')
+ else:
+ required.append('.*?^Optional arguments:')
stdout, stderr = self.shell('help bay-create')
for r in required:
self.assertThat((stdout + stderr),
--
2.36.1

View File

@ -11,6 +11,8 @@ License: {{ license('Apache-2.0') }}
Group: Development/Languages/Python
URL: https://docs.openstack.org/{{ pypi_name }}
Source0: {{ source }}
# Upstream Ibee09bf76399849f7da987c4661fa1945d27afb7
Patch1: 0001-Fix-test_help_on_subcommand-on-Python-3.10.patch
BuildRequires: openstack-macros
BuildRequires: {{ py3('PrettyTable') }}
BuildRequires: {{ py3('cryptography') }}