Skip to content

Commit

Permalink
Fix exec() / locals() interaction, changed in 3.13.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Oct 14, 2024
1 parent 9152e8c commit 4e78874
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/test_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,9 @@ class TestInjectorStats:
def test_stats(self, cb_args, expected, injector):
def callback_factory():
args = ", ".join([f"{k}: {v.__name__}" for k, v in cb_args.items()])
exec(f"def callback(response: DummyResponse, {args}): pass")
return locals().get("callback")
ns = {}
exec(f"def callback(response: DummyResponse, {args}): pass", None, ns)
return ns["callback"]

callback = callback_factory()
response = get_response_for_testing(callback)
Expand Down

0 comments on commit 4e78874

Please sign in to comment.