mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-126390: Support for preserving order of options and nonoption arguments in gnu_getopt() (GH-126393)
This commit is contained in:
parent
12ca7e622f
commit
35010b8cf2
5 changed files with 48 additions and 5 deletions
|
@ -173,6 +173,12 @@ class GetoptTests(unittest.TestCase):
|
|||
self.assertEqual(args, ['-'])
|
||||
self.assertEqual(opts, [('-a', ''), ('-b', '-')])
|
||||
|
||||
# Return positional arguments intermixed with options.
|
||||
opts, args = getopt.gnu_getopt(cmdline, '-ab:', ['alpha', 'beta='])
|
||||
self.assertEqual(args, ['arg2'])
|
||||
self.assertEqual(opts, [('-a', ''), (None, ['arg1']), ('-b', '1'), ('--alpha', ''),
|
||||
('--beta', '2'), ('--beta', '3')])
|
||||
|
||||
# Posix style via +
|
||||
opts, args = getopt.gnu_getopt(cmdline, '+ab:', ['alpha', 'beta='])
|
||||
self.assertEqual(opts, [('-a', '')])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue