mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] gh-121018: Ensure ArgumentParser.parse_args with exit_on_error=False raises instead of exiting when given unrecognized arguments (GH-121019) (GH-121031)
(cherry picked from commit 0654336dd5
)
Co-authored-by: blhsing <blhsing@gmail.com>
This commit is contained in:
parent
6de373d750
commit
4868d1bab1
3 changed files with 9 additions and 2 deletions
|
@ -5743,6 +5743,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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue