(self)
| 6586 | self.assertRegex(str(cm.exception), r'\.\.\.') |
| 6587 | |
| 6588 | def test_required_exclusive(self): |
| 6589 | # required mutually exclusive group; intermixed works fine |
| 6590 | parser = argparse.ArgumentParser(prog='PROG', exit_on_error=False) |
| 6591 | group = parser.add_mutually_exclusive_group(required=True) |
| 6592 | group.add_argument('--foo', action='store_true', help='FOO') |
| 6593 | group.add_argument('--spam', help='SPAM') |
| 6594 | parser.add_argument('badger', nargs='*', default='X', help='BADGER') |
| 6595 | args = parser.parse_intermixed_args('--foo 1 2'.split()) |
| 6596 | self.assertEqual(NS(badger=['1', '2'], foo=True, spam=None), args) |
| 6597 | args = parser.parse_intermixed_args('1 --foo 2'.split()) |
| 6598 | self.assertEqual(NS(badger=['1', '2'], foo=True, spam=None), args) |
| 6599 | self.assertRaisesRegex(argparse.ArgumentError, |
| 6600 | 'one of the arguments --foo --spam is required', |
| 6601 | parser.parse_intermixed_args, '1 2'.split()) |
| 6602 | self.assertEqual(group.required, True) |
| 6603 | |
| 6604 | def test_required_exclusive_with_positional(self): |
| 6605 | # required mutually exclusive group with positional argument |
nothing calls this directly
no test coverage detected