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

Method test_placeholders

Lib/test/test_functools.py:232–254  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

230 self.partial(capture, *args)
231
232 def test_placeholders(self):
233 PH = self.module.Placeholder
234 # 1 Placeholder
235 args = (PH, 0)
236 p = self.partial(capture, *args)
237 actual_args, actual_kwds = p('x')
238 self.assertEqual(actual_args, ('x', 0))
239 self.assertEqual(actual_kwds, {})
240 # 2 Placeholders
241 args = (PH, 0, PH, 1)
242 p = self.partial(capture, *args)
243 with self.assertRaises(TypeError):
244 p('x')
245 actual_args, actual_kwds = p('x', 'y')
246 self.assertEqual(actual_args, ('x', 0, 'y', 1))
247 self.assertEqual(actual_kwds, {})
248 # Checks via `is` and not `eq`
249 # thus ALWAYS_EQ isn't treated as Placeholder
250 p = self.partial(capture, ALWAYS_EQ)
251 actual_args, actual_kwds = p()
252 self.assertEqual(len(actual_args), 1)
253 self.assertIs(actual_args[0], ALWAYS_EQ)
254 self.assertEqual(actual_kwds, {})
255
256 def test_placeholders_optimization(self):
257 PH = self.module.Placeholder

Callers

nothing calls this directly

Calls 6

lenFunction · 0.85
partialMethod · 0.80
pFunction · 0.50
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected