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

Method test_basic

Lib/test/test_capi/test_getargs.py:1244–1263  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1242 (), {}, '', [42])
1243
1244 def test_basic(self):
1245 parse = _testcapi.parse_tuple_and_keywords
1246
1247 self.assertEqual(parse((), {'a': 1}, 'O', ['a']), (1,))
1248 self.assertEqual(parse((), {}, '|O', ['a']), (NULL,))
1249 self.assertEqual(parse((1, 2), {}, 'OO', ['a', 'b']), (1, 2))
1250 self.assertEqual(parse((1,), {'b': 2}, 'OO', ['a', 'b']), (1, 2))
1251 self.assertEqual(parse((), {'a': 1, 'b': 2}, 'OO', ['a', 'b']), (1, 2))
1252 self.assertEqual(parse((), {'b': 2}, '|OO', ['a', 'b']), (NULL, 2))
1253
1254 with self.assertRaisesRegex(TypeError,
1255 "function missing required argument 'a'"):
1256 parse((), {}, 'O', ['a'])
1257 with self.assertRaisesRegex(TypeError,
1258 "this function got an unexpected keyword argument 'b'"):
1259 parse((), {'b': 1}, '|O', ['a'])
1260 with self.assertRaisesRegex(TypeError,
1261 fr"argument for function given by name \('a'\) "
1262 fr"and position \(1\)"):
1263 parse((1,), {'a': 2}, 'O|O', ['a', 'b'])
1264
1265 def test_bad_use(self):
1266 # Test handling invalid format and keywords in

Callers

nothing calls this directly

Calls 3

assertRaisesRegexMethod · 0.80
parseFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected