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)
| 302 | |
| 303 | |
| 304 | def 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 | |
| 321 | def metadata_fixture(ddl="function"): |