MCPcopy Index your code
hub / github.com/RustPython/RustPython / test

Method test

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

Source from the content-addressed store, hash-verified

2136 """Test a user-defined type by registering it"""
2137
2138 def test(self):
2139
2140 def get_my_type(string):
2141 return 'my_type{%s}' % string
2142
2143 parser = argparse.ArgumentParser()
2144 parser.register('type', 'my_type', get_my_type)
2145 parser.add_argument('-x', type='my_type')
2146 parser.add_argument('y', type='my_type')
2147
2148 self.assertEqual(parser.parse_args('1'.split()),
2149 NS(x=None, y='my_type{1}'))
2150 self.assertEqual(parser.parse_args('-x 1 42'.split()),
2151 NS(x='my_type{1}', y='my_type{42}'))
2152
2153
2154# ============

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