From 84478d83f87e9993625044de5cd8b4a18dfcaf5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Thu, 29 Sep 2022 09:59:31 +0200 Subject: Make tests backward compat with cliff' older versions Change the assertion kind to support all versions of cliff. The previous related fix 78098e6b18026ff9ef03a948b57348f02d42e13b was only compatible with cliff>3.4.0. Change-Id: I7ac27919b0d58929b4c975ebb308f33124a6060f --- oslo_config/tests/test_cfg.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index ec2791e..926eb8c 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -5077,13 +5077,13 @@ class DeprecationWarningTests(DeprecationWarningTestBase): def assert_message_logged(self, deprecated_name, deprecated_group, current_name, current_group): - expected = ('Deprecated: ' + cfg._Namespace._deprecated_opt_message % + expected = (cfg._Namespace._deprecated_opt_message % {'dep_option': deprecated_name, 'dep_group': deprecated_group, 'option': current_name, 'group': current_group} ) - self.assertEqual(expected + '\n', self.log_fixture.output) + self.assertIn(expected + '\n', self.log_fixture.output) def test_deprecated_for_removal(self): self.conf.register_opt(cfg.StrOpt('foo', @@ -5099,10 +5099,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 = ('Deprecated: Option "foo" from group "DEFAULT" is ' + expected = ('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) + self.assertIn(expected, self.log_fixture.output) def test_deprecated_for_removal_with_group(self): self.conf.register_group(cfg.OptGroup('other')) @@ -5121,10 +5121,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 = ('Deprecated: Option "foo" from group "other" is ' + expected = ('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) + self.assertIn(expected, self.log_fixture.output) def test_deprecated_with_dest(self): self.conf.register_group(cfg.OptGroup('other')) @@ -5138,12 +5138,12 @@ class DeprecationWarningTests(DeprecationWarningTestBase): self.conf(['--config-file', paths[0]]) self.assertEqual('baz', self.conf.other.foo) - expected = ('Deprecated: ' + cfg._Namespace._deprecated_opt_message % + expected = (cfg._Namespace._deprecated_opt_message % {'dep_option': 'bar', 'dep_group': 'other', 'option': 'foo-bar', 'group': 'other'} + '\n') - self.assertEqual(expected, self.log_fixture.output) + self.assertIn(expected, self.log_fixture.output) class DeprecationWarningTestsNoOsloLog(DeprecationWarningTests): -- cgit v1.2.1