summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Roelandt <cyril@redhat.com>2021-08-19 00:26:46 +0000
committerCyril Roelandt <cyril@redhat.com>2021-08-19 00:42:44 +0000
commit88c831cfadfe99d6fa75d5dfcd5a871f7d8c7a38 (patch)
treea5049e2a3e16a77895ba5332c5de6329da8530a6
parent1a7bd66a7179ca374e996e76f346def33787a21f (diff)
downloadoslo-config-88c831cfadfe99d6fa75d5dfcd5a871f7d8c7a38.tar.gz
Fix tests for Python3.
Change-Id: Ifbf6f52a312929ac07154db8eeee976b0ab0d46a
-rw-r--r--oslo_config/tests/test_cfg.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py
index 4c3db7e..60032e6 100644
--- a/oslo_config/tests/test_cfg.py
+++ b/oslo_config/tests/test_cfg.py
@@ -184,7 +184,10 @@ class HelpTestCase(BaseTestCase):
'usage: test [-h] [--config-dir DIR] [--config-file PATH] '
'[--version]',
f.getvalue())
- self.assertIn('optional', f.getvalue())
+ # argparse may generate two different help messages:
+ # - In Python >=3.10: "options:\n --version"
+ # - In Python <3.10: "optional arguments:"
+ self.assertRegex(f.getvalue(), 'option(s|al arguments):')
self.assertIn('-h, --help', f.getvalue())
def test_print_strOpt_with_choices_help(self):
@@ -207,7 +210,10 @@ class HelpTestCase(BaseTestCase):
'usage: test [-h] [--aa AA] [--bb BB] [--cc CC] [--config-dir DIR]'
'\n [--config-file PATH] [--version]',
f.getvalue())
- self.assertIn('optional', f.getvalue())
+ # argparse may generate two different help messages:
+ # - In Python >=3.10: "options:\n --version"
+ # - In Python <3.10: "optional arguments:"
+ self.assertRegex(f.getvalue(), 'option(s|al arguments):')
self.assertIn('-h, --help', f.getvalue())
self.assertIn('StrOpt with choices. Allowed values: xx, yy, zz',
f.getvalue())