gh-131178: Fix test_unknown_flag for platform CLI (#137816)

This commit is contained in:
Semyon Moroz 2025-09-05 11:29:46 +00:00 committed by GitHub
parent ed53c63769
commit e76464d161
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -770,13 +770,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 = (