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)
| 343 | |
| 344 | |
| 345 | def 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 | |
| 362 | def metadata_fixture(ddl="function"): |