changeset: 104522:26249f82c15d branch: 3.6 parent: 104519:0b29adb5c804 parent: 104521:af06d9616c29 user: Victor Stinner date: Mon Oct 17 18:13:46 2016 +0200 files: Lib/test/libregrtest/cmdline.py Lib/test/libregrtest/refleak.py Lib/test/libregrtest/save_env.py Lib/test/regrtest.py Lib/test/test_regrtest.py Misc/NEWS description: Merge 3.6: Issue #28409: regrtest: fix the parser of command line arguments. diff -r 0b29adb5c804 -r 26249f82c15d Lib/test/libregrtest/cmdline.py --- a/Lib/test/libregrtest/cmdline.py Mon Oct 17 06:14:48 2016 +0300 +++ b/Lib/test/libregrtest/cmdline.py Mon Oct 17 18:13:46 2016 +0200 @@ -242,9 +242,6 @@ group.add_argument('-P', '--pgo', dest='pgo', action='store_true', help='enable Profile Guided Optimization training') - parser.add_argument('args', nargs='*', - help=argparse.SUPPRESS) - return parser @@ -294,7 +291,13 @@ ns.use_resources = [] parser = _create_parser() - parser.parse_args(args=args, namespace=ns) + # Issue #14191: argparse doesn't support "intermixed" positional and + # optional arguments. Use parse_known_args() as workaround. + ns.args = parser.parse_known_args(args=args, namespace=ns)[1] + for arg in ns.args: + if arg.startswith('-'): + parser.error("unrecognized arguments: %s" % arg) + sys.exit(1) if ns.single and ns.fromfile: parser.error("-s and -f don't go together!") diff -r 0b29adb5c804 -r 26249f82c15d Lib/test/test_regrtest.py --- a/Lib/test/test_regrtest.py Mon Oct 17 06:14:48 2016 +0300 +++ b/Lib/test/test_regrtest.py Mon Oct 17 18:13:46 2016 +0200 @@ -299,6 +299,15 @@ self.assertEqual(ns.verbose, 0) self.assertEqual(ns.args, ['foo']) + def test_arg_option_arg(self): + ns = libregrtest._parse_args(['test_unaryop', '-v', 'test_binop']) + self.assertEqual(ns.verbose, 1) + self.assertEqual(ns.args, ['test_unaryop', 'test_binop']) + + def test_unknown_option(self): + self.checkError(['--unknown-option'], + 'unrecognized arguments: --unknown-option') + class BaseTestCase(unittest.TestCase): TEST_UNIQUE_ID = 1 diff -r 0b29adb5c804 -r 26249f82c15d Misc/NEWS --- a/Misc/NEWS Mon Oct 17 06:14:48 2016 +0300 +++ b/Misc/NEWS Mon Oct 17 18:13:46 2016 +0200 @@ -25,6 +25,11 @@ - Issue #28248: Update Windows build to use OpenSSL 1.0.2j. +Tests +----- + +- Issue #28409: regrtest: fix the parser of command line arguments. + What's New in Python 3.6.0 beta 2 =================================