#4458: recognize "-" as an argument, not a malformed option in gnu_getopt().

This commit is contained in:
Georg Brandl 2008-12-05 09:23:14 +00:00
parent 8d6c49047f
commit a07435d3e3
3 changed files with 9 additions and 1 deletions

View file

@ -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', '')])