[3.13] gh-121018: Ensure ArgumentParser.parse_args with exit_on_error=False raises instead of exiting when given unrecognized arguments (GH-121019) (GH-121032)

(cherry picked from commit 0654336dd5)

Co-authored-by: blhsing <blhsing@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-06-26 12:16:19 +02:00 committed by GitHub
parent f2b4f517b9
commit 6bc7e2cca5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View file

@ -6096,6 +6096,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.