diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index e4c9c38989e..3c12aff4cb7 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -226,8 +226,8 @@ class ParserTesterMetaclass(type): parser = self._get_parser(tester) for args_str in tester.failures: args = args_str.split() - raises = tester.assertRaises - raises(ArgumentParserError, parser.parse_args, args) + with tester.assertRaises(ArgumentParserError, msg=args): + parser.parse_args(args) def test_successes(self, tester): parser = self._get_parser(tester)