diff --git a/tests/utest/oxygen_handler_result/test_deprecation_warning.py b/tests/utest/oxygen_handler_result/test_deprecation_warning.py index a156c84..85bde73 100644 --- a/tests/utest/oxygen_handler_result/test_deprecation_warning.py +++ b/tests/utest/oxygen_handler_result/test_deprecation_warning.py @@ -19,17 +19,20 @@ class TestDeprecationWarningWhenValidating(TestCase): def setUp(self): self.cli = OxygenCLI() + def _validate_warning_msg(self, warning, module_name): + warning_message = str(warning.warning) + for expected in (module_name, + 'validation error for typed-dict', + 'In Oxygen 1.0, handlers will need to produce valid results.'): + self.assertIn(expected, warning_message) + def test_warning_about_invalid_result(self): handler = BaseHandler(get_config()['oxygen.junit']) with self.assertWarns(UserWarning) as warning: handler._validate({}) - warning_message = str(warning.warning) - self.assertIn('oxygen.base_handler', warning_message) - self.assertIn('validation error for typed-dict', warning_message) - self.assertIn('In Oxygen 1.0, handlers will' - ' need to produce valid results.', warning_message) + self._validate_warning_msg(warning, 'oxygen.base_handler') @patch('oxygen.oxygen.RobotInterface') def test_warning_about_invalid_result_in_CLI(self, mock_iface): @@ -39,7 +42,9 @@ def test_warning_about_invalid_result_in_CLI(self, mock_iface): 'func': lambda **_: {**MINIMAL_SUITE_DICT, 'setup': []} }) - mock_iface.assert_any_call() + mock_iface.assert_any_call() + # this one has weird name because we fake `func` with lambda + self._validate_warning_msg(warning, 'test_deprecation_warning') def test_deprecation_was_removed(self): '''Remove this test once deprecation warning has been removed'''