diff options
author | blhsing <blhsing@gmail.com> | 2024-06-26 07:41:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-26 07:41:51 (GMT) |
commit | 0654336dd5138aec04e3017e15ccbb90a44e053d (patch) | |
tree | 5bb24608c03a07c7ce19627d7efb09b01169daaa /Lib/test/test_argparse.py | |
parent | 82235449b85165add62c1b200299456a50a1d097 (diff) | |
download | cpython-0654336dd5138aec04e3017e15ccbb90a44e053d.zip cpython-0654336dd5138aec04e3017e15ccbb90a44e053d.tar.gz cpython-0654336dd5138aec04e3017e15ccbb90a44e053d.tar.bz2 |
gh-121018: Ensure ArgumentParser.parse_args with exit_on_error=False raises instead of exiting when given unrecognized arguments (GH-121019)
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index eb1a9f5..11eb081 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -6053,6 +6053,9 @@ class TestExitOnError(TestCase): with self.assertRaises(argparse.ArgumentError): self.parser.parse_args('--integers a'.split()) + def test_exit_on_error_with_unrecognized_args(self): + with self.assertRaises(argparse.ArgumentError): + self.parser.parse_args('--foo bar'.split()) def tearDownModule(): # Remove global references to avoid looking like we have refleaks. |