diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 479649053abc01..976e540394b4f7 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -762,13 +762,14 @@ def invoke_platform(self, *flags): 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 = (