summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-09-29 07:44:34 (GMT)
committerGitHub <noreply@github.com>2024-09-29 07:44:34 (GMT)
commit49e105f9488de18d3d92948232fcbd956cbe0c6e (patch)
tree69c33024170ad29548aebad862df000d4d93c781 /Lib/test/test_argparse.py
parentd08c7888229e78533648191dfe42e2d2d3ecea25 (diff)
downloadcpython-49e105f9488de18d3d92948232fcbd956cbe0c6e.zip
cpython-49e105f9488de18d3d92948232fcbd956cbe0c6e.tar.gz
cpython-49e105f9488de18d3d92948232fcbd956cbe0c6e.tar.bz2
gh-104860: Fix allow_abbrev=False for single-dash long options (GH-124340)
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index ef05a6f..26e32c3 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -914,6 +914,23 @@ class TestOptionalsDisallowLongAbbreviationPrefixChars(ParserTestCase):
]
+class TestOptionalsDisallowSingleDashLongAbbreviation(ParserTestCase):
+ """Do not allow abbreviations of long options at all"""
+
+ parser_signature = Sig(allow_abbrev=False)
+ argument_signatures = [
+ Sig('-foo'),
+ Sig('-foodle', action='store_true'),
+ Sig('-foonly'),
+ ]
+ failures = ['-foon 3', '-food', '-food -foo 2']
+ successes = [
+ ('', NS(foo=None, foodle=False, foonly=None)),
+ ('-foo 3', NS(foo='3', foodle=False, foonly=None)),
+ ('-foonly 7 -foodle -foo 2', NS(foo='2', foodle=True, foonly='7')),
+ ]
+
+
class TestDisallowLongAbbreviationAllowsShortGrouping(ParserTestCase):
"""Do not allow abbreviations of long options at all"""