]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131178: Fix `test_unknown_flag` for platform CLI (#137816)
authorSemyon Moroz <donbarbos@proton.me>
Fri, 5 Sep 2025 11:29:46 +0000 (11:29 +0000)
committerGitHub <noreply@github.com>
Fri, 5 Sep 2025 11:29:46 +0000 (16:59 +0530)
Lib/test/test_platform.py

index 601d450b7de9eb8e94b1f632978215edf3c9341b..c07f96aecf4a7849a45b7b83590df9ee7a45682a 100644 (file)
@@ -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 = (