From e76464d161f2e7f2c27c84f8de4de5f88f025973 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Fri, 5 Sep 2025 11:29:46 +0000 Subject: [PATCH] gh-131178: Fix `test_unknown_flag` for platform CLI (#137816) --- Lib/test/test_platform.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 601d450b7de9..c07f96aecf4a 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -770,13 +770,14 @@ class CommandLineTest(unittest.TestCase): platform._main(args=flags) return output.getvalue() + @support.force_not_colorized def test_unknown_flag(self): + output = io.StringIO() with self.assertRaises(SystemExit): - output = io.StringIO() # suppress argparse error message with contextlib.redirect_stderr(output): _ = self.invoke_platform('--unknown') - self.assertStartsWith(output, "usage: ") + self.assertStartsWith(output.getvalue(), "usage: ") def test_invocation(self): flags = ( -- 2.47.3