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

Method test

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

Source from the content-addressed store, hash-verified

2235 """Test a user-defined type by registering it"""
2236
2237 def test(self):
2238
2239 def get_my_type(string):
2240 return 'my_type{%s}' % string
2241
2242 parser = argparse.ArgumentParser()
2243 parser.register('type', 'my_type', get_my_type)
2244 parser.add_argument('-x', type='my_type')
2245 parser.add_argument('y', type='my_type')
2246
2247 self.assertEqual(parser.parse_args('1'.split()),
2248 NS(x=None, y='my_type{1}'))
2249 self.assertEqual(parser.parse_args('-x 1 42'.split()),
2250 NS(x='my_type{1}', y='my_type{42}'))
2251
2252
2253# ============

Callers

nothing calls this directly

Calls 6

parse_argsMethod · 0.95
NSClass · 0.70
registerMethod · 0.45
add_argumentMethod · 0.45
assertEqualMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected