MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / resolve_lambda

Function resolve_lambda

lib/sqlalchemy/testing/util.py:304–318  ·  view source on GitHub ↗

Given a no-arg lambda and a namespace, return a new lambda that has all the values filled in. This is used so that we can have module-level fixtures that refer to instance-level variables using lambdas.

(__fn, **kw)

Source from the content-addressed store, hash-verified

302
303
304def resolve_lambda(__fn, **kw):
305 """Given a no-arg lambda and a namespace, return a new lambda that
306 has all the values filled in.
307
308 This is used so that we can have module-level fixtures that
309 refer to instance-level variables using lambdas.
310
311 """
312
313 pos_args = inspect_getfullargspec(__fn)[0]
314 pass_pos_args = {arg: kw.pop(arg) for arg in pos_args}
315 glb = dict(__fn.__globals__)
316 glb.update(kw)
317 new_fn = types.FunctionType(__fn.__code__, glb)
318 return new_fn(**pass_pos_args)
319
320
321def metadata_fixture(ddl="function"):

Callers 9

test_other_exprsMethod · 0.90
test_like_opsMethod · 0.90
test_autoflushesMethod · 0.90
test_params_with_joinMethod · 0.90
test_simple_compileMethod · 0.90
test_simple_compileMethod · 0.90
test_simple_compileMethod · 0.90

Calls 3

inspect_getfullargspecFunction · 0.85
popMethod · 0.45
updateMethod · 0.45

Tested by 9

test_other_exprsMethod · 0.72
test_like_opsMethod · 0.72
test_autoflushesMethod · 0.72
test_params_with_joinMethod · 0.72
test_simple_compileMethod · 0.72
test_simple_compileMethod · 0.72
test_simple_compileMethod · 0.72