From d538d6ed68dcd7b6f71256182cfe7fe246537181 Mon Sep 17 00:00:00 2001 From: "Dr. Jens Harbott" Date: Wed, 22 Dec 2021 21:10:50 +0100 Subject: [PATCH] Fix TestTagHelps for python3.10 With pytheon3.10 the naming of the "optional arguments" section has been changed to "options"[0]. Adapt the reference texts accordingly. [0] https://docs.python.org/3/whatsnew/3.10.html#argparse Signed-off-by: Dr. Jens Harbott Change-Id: I4c572153b53ca381e2f100456bf77f6fe2892b5c --- osc_lib/tests/utils/test_tags.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/osc_lib/tests/utils/test_tags.py b/osc_lib/tests/utils/test_tags.py index 87f7380..7737c47 100644 --- a/osc_lib/tests/utils/test_tags.py +++ b/osc_lib/tests/utils/test_tags.py @@ -13,6 +13,7 @@ # under the License. import argparse +import sys from unittest import mock from osc_lib.tests import utils as test_utils @@ -186,13 +187,17 @@ class TestTagHelps(test_utils.TestCase): :param exp_enhanced: Expected output with ``enhance_help`` set to ``help_enhancer`` """ + if sys.version_info >= (3, 10): + options_name = 'options' + else: + options_name = 'optional arguments' parser = argparse.ArgumentParser() meth(parser, 'test') - self.assertEqual(exp_normal, parser.format_help()) + self.assertEqual(exp_normal % options_name, parser.format_help()) parser = argparse.ArgumentParser() meth(parser, 'test', enhance_help=help_enhancer) - self.assertEqual(exp_enhanced, parser.format_help()) + self.assertEqual(exp_enhanced % options_name, parser.format_help()) def test_add_tag_filtering_option_to_parser(self): self._test_tag_method_help( @@ -202,7 +207,7 @@ usage: run.py [-h] [--tags [,,...]] [--any-tags [,,...]] [--not-tags [,,...]] [--not-any-tags [,,...]] -optional arguments: +%s: -h, --help show this help message and exit --tags [,,...] List test which have all given tag(s) (Comma-separated @@ -222,7 +227,7 @@ usage: run.py [-h] [--tags [,,...]] [--any-tags [,,...]] [--not-tags [,,...]] [--not-any-tags [,,...]] -optional arguments: +%s: -h, --help show this help message and exit --tags [,,...] )sgat fo tsil detarapes-ammoC( )s(gat nevig lla evah @@ -244,7 +249,7 @@ optional arguments: """\ usage: run.py [-h] [--tag | --no-tag] -optional arguments: +%s: -h, --help show this help message and exit --tag Tag to be added to the test (repeat option to set multiple tags) @@ -253,7 +258,7 @@ optional arguments: """\ usage: run.py [-h] [--tag | --no-tag] -optional arguments: +%s: -h, --help show this help message and exit --tag )sgat elpitlum tes ot noitpo taeper( tset eht ot dedda eb ot gaT @@ -266,7 +271,7 @@ optional arguments: """\ usage: run.py [-h] [--tag ] [--no-tag] -optional arguments: +%s: -h, --help show this help message and exit --tag Tag to be added to the test (repeat option to set multiple tags) @@ -276,7 +281,7 @@ optional arguments: """\ usage: run.py [-h] [--tag ] [--no-tag] -optional arguments: +%s: -h, --help show this help message and exit --tag )sgat elpitlum tes ot noitpo taeper( tset eht ot dedda eb ot gaT @@ -290,7 +295,7 @@ optional arguments: """\ usage: run.py [-h] [--tag | --all-tag] -optional arguments: +%s: -h, --help show this help message and exit --tag Tag to be removed from the test (repeat option to remove multiple tags) @@ -299,7 +304,7 @@ optional arguments: """\ usage: run.py [-h] [--tag | --all-tag] -optional arguments: +%s: -h, --help show this help message and exit --tag )sgat elpitlum evomer ot noitpo taeper( tset eht morf devomer eb ot gaT