mirror of
https://github.com/python/cpython.git
synced 2025-11-08 05:39:34 +00:00
Merge 3.6: Issue #28409: regrtest: fix the parser of command line arguments.
This commit is contained in:
commit
a506a93b0b
3 changed files with 21 additions and 4 deletions
|
|
@ -242,9 +242,6 @@ def _create_parser():
|
||||||
group.add_argument('-P', '--pgo', dest='pgo', action='store_true',
|
group.add_argument('-P', '--pgo', dest='pgo', action='store_true',
|
||||||
help='enable Profile Guided Optimization training')
|
help='enable Profile Guided Optimization training')
|
||||||
|
|
||||||
parser.add_argument('args', nargs='*',
|
|
||||||
help=argparse.SUPPRESS)
|
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -294,7 +291,13 @@ def _parse_args(args, **kwargs):
|
||||||
ns.use_resources = []
|
ns.use_resources = []
|
||||||
|
|
||||||
parser = _create_parser()
|
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:
|
if ns.single and ns.fromfile:
|
||||||
parser.error("-s and -f don't go together!")
|
parser.error("-s and -f don't go together!")
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,15 @@ class ParseArgsTestCase(unittest.TestCase):
|
||||||
self.assertEqual(ns.verbose, 0)
|
self.assertEqual(ns.verbose, 0)
|
||||||
self.assertEqual(ns.args, ['foo'])
|
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):
|
class BaseTestCase(unittest.TestCase):
|
||||||
TEST_UNIQUE_ID = 1
|
TEST_UNIQUE_ID = 1
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ Build
|
||||||
|
|
||||||
- Issue #28248: Update Windows build to use OpenSSL 1.0.2j.
|
- 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
|
What's New in Python 3.6.0 beta 2
|
||||||
=================================
|
=================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue