Fix test_sub_command_multiple on Python 3.12.5+
Update the expectations in test_sub_command_multiple for different argparse error handling in Python 3.12.5 and newer. Previously, the 'cannot have multiple subparser arguments' error would be output to stderr and cause the parser to exit; now it raises an ArgumentError instead. Closes-Bug: 2074130 Change-Id: I83de6b6943b14f1f6df86a55603e6867dce680d3 Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
parent
beb7b6ce2b
commit
972d304bb2
@ -4385,8 +4385,12 @@ class SubCommandTestCase(BaseTestCase):
|
||||
self.conf.register_cli_opt(cfg.SubCommandOpt('cmd1'))
|
||||
self.conf.register_cli_opt(cfg.SubCommandOpt('cmd2'))
|
||||
self.useFixture(fixtures.MonkeyPatch('sys.stderr', io.StringIO()))
|
||||
self.assertRaises(SystemExit, self.conf, [])
|
||||
self.assertIn('multiple', sys.stderr.getvalue())
|
||||
if sys.version_info >= (3, 12, 5):
|
||||
self.assertRaisesRegex(argparse.ArgumentError, 'multiple',
|
||||
self.conf, [])
|
||||
else:
|
||||
self.assertRaises(SystemExit, self.conf, [])
|
||||
self.assertIn('multiple', sys.stderr.getvalue())
|
||||
|
||||
|
||||
class SetDefaultsTestCase(BaseTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user