diff options
author | Hervé Beraud <hberaud@redhat.com> | 2022-08-02 16:28:53 +0200 |
---|---|---|
committer | Hervé Beraud <hberaud@redhat.com> | 2022-08-03 16:47:25 +0200 |
commit | 78098e6b18026ff9ef03a948b57348f02d42e13b (patch) | |
tree | 6c11ad4009073d0c4341d51c707ff4069866e14d | |
parent | 9eaae044534cbe015217019781c4c0d97f0402df (diff) | |
download | oslo-config-78098e6b18026ff9ef03a948b57348f02d42e13b.tar.gz |
fix CLI mismatch in unit tests
Since cliff > 3.4.0 we can see mismatch errors with unit tests, this
patch fix this error.
Also this patch fix some issues with deprecation messages.
All these issues needs to be fixed together to unlock our gates.
Closes-bug: #1908934
Change-Id: I8396b4f3ba74a9ea023bff2e3027710f16a74af4
-rw-r--r-- | oslo_config/tests/test_cfg.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index 60032e6..16ec21d 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -207,8 +207,8 @@ class HelpTestCase(BaseTestCase): self.conf([]) self.conf.print_help(file=f) self.assertIn( - 'usage: test [-h] [--aa AA] [--bb BB] [--cc CC] [--config-dir DIR]' - '\n [--config-file PATH] [--version]', + 'usage: test [-h] [--aa AA] [--bb BB] [--cc CC] ' + '[--config-dir DIR]', f.getvalue()) # argparse may generate two different help messages: # - In Python >=3.10: "options:\n --version" @@ -5074,14 +5074,13 @@ class DeprecationWarningTests(DeprecationWarningTestBase): def assert_message_logged(self, deprecated_name, deprecated_group, current_name, current_group): - expected = (cfg._Namespace._deprecated_opt_message % + expected = ('Deprecated: ' + cfg._Namespace._deprecated_opt_message % {'dep_option': deprecated_name, 'dep_group': deprecated_group, 'option': current_name, 'group': current_group} ) - self.assertEqual(self.log_prefix + expected + '\n', - self.log_fixture.output) + self.assertEqual(expected + '\n', self.log_fixture.output) def test_deprecated_for_removal(self): self.conf.register_opt(cfg.StrOpt('foo', @@ -5097,10 +5096,10 @@ class DeprecationWarningTests(DeprecationWarningTestBase): self.assertEqual('bar', self.conf.foo) # Options not set in the config should not be logged. self.assertIsNone(self.conf.bar) - expected = ('Option "foo" from group "DEFAULT" is deprecated for ' - 'removal. Its value may be silently ignored in the ' - 'future.\n') - self.assertEqual(self.log_prefix + expected, self.log_fixture.output) + expected = ('Deprecated: Option "foo" from group "DEFAULT" is ' + 'deprecated for removal. Its value may be silently ' + 'ignored in the future.\n') + self.assertEqual(expected, self.log_fixture.output) def test_deprecated_for_removal_with_group(self): self.conf.register_group(cfg.OptGroup('other')) @@ -5119,10 +5118,10 @@ class DeprecationWarningTests(DeprecationWarningTestBase): self.assertEqual('bar', self.conf.other.foo) # Options not set in the config should not be logged. self.assertIsNone(self.conf.other.bar) - expected = ('Option "foo" from group "other" is deprecated for ' - 'removal. Its value may be silently ignored in the ' - 'future.\n') - self.assertEqual(self.log_prefix + expected, self.log_fixture.output) + expected = ('Deprecated: Option "foo" from group "other" is ' + 'deprecated for removal. Its value may be silently ' + 'ignored in the future.\n') + self.assertEqual(expected, self.log_fixture.output) def test_deprecated_with_dest(self): self.conf.register_group(cfg.OptGroup('other')) @@ -5136,12 +5135,12 @@ class DeprecationWarningTests(DeprecationWarningTestBase): self.conf(['--config-file', paths[0]]) self.assertEqual('baz', self.conf.other.foo) - expected = (cfg._Namespace._deprecated_opt_message % + expected = ('Deprecated: ' + cfg._Namespace._deprecated_opt_message % {'dep_option': 'bar', 'dep_group': 'other', 'option': 'foo-bar', 'group': 'other'} + '\n') - self.assertEqual(self.log_prefix + expected, self.log_fixture.output) + self.assertEqual(expected, self.log_fixture.output) class DeprecationWarningTestsNoOsloLog(DeprecationWarningTests): |