diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index b1f72a3abd46a1..d28d90d043933a 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -5834,9 +5834,8 @@ def test_invalid_args(self): parser = ErrorRaisingArgumentParser(prog='PROG') parser.add_argument('--foo', nargs="*") parser.add_argument('foo') - with captured_stderr() as stderr: + with self.assertWarns(UserWarning): parser.parse_intermixed_args(['hello', '--foo']) - self.assertIn("UserWarning", stderr.getvalue()) class TestIntermixedMessageContentError(TestCase): # case where Intermixed gives different error message