MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / resolve_lambda

Function resolve_lambda

lib/sqlalchemy/testing/util.py:345–359  ·  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

343
344
345def resolve_lambda(__fn, **kw):
346 """Given a no-arg lambda and a namespace, return a new lambda that
347 has all the values filled in.
348
349 This is used so that we can have module-level fixtures that
350 refer to instance-level variables using lambdas.
351
352 """
353
354 pos_args = inspect_getfullargspec(__fn)[0]
355 pass_pos_args = {arg: kw.pop(arg) for arg in pos_args}
356 glb = dict(__fn.__globals__)
357 glb.update(kw)
358 new_fn = types.FunctionType(__fn.__code__, glb)
359 return new_fn(**pass_pos_args)
360
361
362def metadata_fixture(ddl="function"):

Callers 6

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

Calls 3

inspect_getfullargspecFunction · 0.85
popMethod · 0.45
updateMethod · 0.45

Tested by 6

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