(self)
| 6719 | self.assertRegex(str(cm.exception), r'\.\.\.') |
| 6720 | |
| 6721 | def test_required_exclusive(self): |
| 6722 | # required mutually exclusive group; intermixed works fine |
| 6723 | parser = argparse.ArgumentParser(prog='PROG', exit_on_error=False) |
| 6724 | group = parser.add_mutually_exclusive_group(required=True) |
| 6725 | group.add_argument('--foo', action='store_true', help='FOO') |
| 6726 | group.add_argument('--spam', help='SPAM') |
| 6727 | parser.add_argument('badger', nargs='*', default='X', help='BADGER') |
| 6728 | args = parser.parse_intermixed_args('--foo 1 2'.split()) |
| 6729 | self.assertEqual(NS(badger=['1', '2'], foo=True, spam=None), args) |
| 6730 | args = parser.parse_intermixed_args('1 --foo 2'.split()) |
| 6731 | self.assertEqual(NS(badger=['1', '2'], foo=True, spam=None), args) |
| 6732 | self.assertRaisesRegex(argparse.ArgumentError, |
| 6733 | 'one of the arguments --foo --spam is required', |
| 6734 | parser.parse_intermixed_args, '1 2'.split()) |
| 6735 | self.assertEqual(group.required, True) |
| 6736 | |
| 6737 | def test_required_exclusive_with_positional(self): |
| 6738 | # required mutually exclusive group with positional argument |
nothing calls this directly
no test coverage detected