MCPcopy Index your code
hub / github.com/python/cpython / test_parse_args

Method test_parse_args

Lib/test/test_argparse.py:2632–2649  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2630 self.assertEqual(cm.exception.args[2], f'{usage_str}\n{error_str}\n')
2631
2632 def test_parse_args(self):
2633 # check some non-failure cases:
2634 self.assertEqual(
2635 self.parser.parse_args('0.5 1 b -w 7'.split()),
2636 NS(foo=False, bar=0.5, w=7, x='b'),
2637 )
2638 self.assertEqual(
2639 self.parser.parse_args('0.25 --foo 2 -y 2 3j -- -1j'.split()),
2640 NS(foo=True, bar=0.25, y='2', z=[3j, -1j]),
2641 )
2642 self.assertEqual(
2643 self.parser.parse_args('--foo 0.125 1 c'.split()),
2644 NS(foo=True, bar=0.125, w=None, x='c'),
2645 )
2646 self.assertEqual(
2647 self.parser.parse_args('-1.5 3 11 -- a --foo 7 -- b'.split()),
2648 NS(foo=False, bar=-1.5, t=11, u=['a', '--foo', '7', '--', 'b']),
2649 )
2650
2651 def test_parse_known_args(self):
2652 self.assertEqual(

Callers

nothing calls this directly

Calls 4

NSClass · 0.70
assertEqualMethod · 0.45
parse_argsMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected