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

Method test_lambdas

Lib/test/test_positional_only_arg.py:222–234  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

220 self.assertEqual(f(1, 2, 3), 6)
221
222 def test_lambdas(self):
223 x = lambda a, /, b: a + b
224 self.assertEqual(x(1,2), 3)
225 self.assertEqual(x(1,b=2), 3)
226
227 x = lambda a, /, b=2: a + b
228 self.assertEqual(x(1), 3)
229
230 x = lambda a, b, /: a + b
231 self.assertEqual(x(1, 2), 3)
232
233 x = lambda a, b, /, : a + b
234 self.assertEqual(x(1, 2), 3)
235
236 def test_invalid_syntax_lambda(self):
237 check_syntax_error(self, "lambda a, b = 5, /, c: None", "parameter without a default follows parameter with a default")

Callers

nothing calls this directly

Calls 2

xFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected