mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
#4458: recognize "-" as an argument, not a malformed option in gnu_getopt().
This commit is contained in:
parent
8d6c49047f
commit
a07435d3e3
3 changed files with 9 additions and 1 deletions
|
@ -124,6 +124,11 @@ class GetoptTests(unittest.TestCase):
|
|||
self.assertEqual(opts, [('-a', ''), ('-b', '1'),
|
||||
('--alpha', ''), ('--beta', '2')])
|
||||
|
||||
# recognize "-" as an argument
|
||||
opts, args = getopt.gnu_getopt(['-a', '-', '-b', '-'], 'ab:', [])
|
||||
self.assertEqual(args, ['-'])
|
||||
self.assertEqual(opts, [('-a', ''), ('-b', '-')])
|
||||
|
||||
# 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