From feb643e54158f5b786d51488e1eb03ebcf568c0f Mon Sep 17 00:00:00 2001 From: JWM Date: Mon, 25 Nov 2024 22:50:18 +0100 Subject: [PATCH] Update test_cq_description_format to check if warnings were printed --- tests/test_integration.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index f2cbb4f0..5b1f6c48 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -369,10 +369,14 @@ def test_cq_description_format(self, path_cwd_mock): filename = 'code_quality_format.json' out_file = str(TEST_OUT_DIR / filename) ref_file = str(TEST_IN_DIR / filename) - retval = warnings_wrapper([ - '--code-quality', out_file, - '--config', 'tests/test_in/config_cq_description_format.json', - 'tests/test_in/mixed_warnings.txt', - ]) + with patch('sys.stdout', new=StringIO()) as fake_output: + retval = warnings_wrapper([ + '--code-quality', out_file, + '--config', 'tests/test_in/config_cq_description_format.json', + 'tests/test_in/mixed_warnings.txt', + ]) + output = fake_output.getvalue().splitlines(keepends=False) + self.assertIn("WARNING: Unrecognized classification 'max'", output) + self.assertIn("WARNING: Unrecognized classification 'min'", output) self.assertEqual(2, retval) self.assertTrue(filecmp.cmp(out_file, ref_file), '{} differs from {}'.format(out_file, ref_file))