From: Semyon Moroz Date: Fri, 5 Sep 2025 11:29:46 +0000 (+0000) Subject: gh-131178: Fix `test_unknown_flag` for platform CLI (#137816) X-Git-Tag: v3.15.0a1~483 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e76464d161f2e7f2c27c84f8de4de5f88f025973;p=thirdparty%2FPython%2Fcpython.git gh-131178: Fix `test_unknown_flag` for platform CLI (#137816) --- 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 = (