summaryrefslogtreecommitdiff
path: root/Lib/test/test_getopt.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-05 09:23:14 +0000
committerGeorg Brandl <georg@python.org>2008-12-05 09:23:14 +0000
commita07435d3e3dfee3e4d8998baa7fadbfaf46f764d (patch)
tree1c749e787fde8e79d694630fcf18679835613d1a /Lib/test/test_getopt.py
parent8d6c49047f2725ebb67212689e7eef2388dfbcdc (diff)
downloadcpython-git-a07435d3e3dfee3e4d8998baa7fadbfaf46f764d.tar.gz
#4458: recognize "-" as an argument, not a malformed option in gnu_getopt().
Diffstat (limited to 'Lib/test/test_getopt.py')
-rw-r--r--Lib/test/test_getopt.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py
index 36d1688b03..aac720d5a6 100644
--- a/Lib/test/test_getopt.py
+++ b/Lib/test/test_getopt.py
@@ -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', '')])