Skip to content

Commit 340dedd

Browse files
committed
Use an explicit mapping for locals in this test
In Python 3.13 the `locals` function now returns a fresh mapping each time it's called (when called in a function). We thus need to store a reference to the mapping being used, rather than re-fetching it each time. Since we don't actually need to modify the locals within the scope of the test function itself, it suffices to use our own mapping here rather than the result of calling `locals`, which fully isolates this test from the nature of that function. Fixes #2002
1 parent 473b35e commit 340dedd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/test_api/test_interpreter.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,9 @@ def test_completion_param_annotations():
310310
# Need to define this function not directly in Python. Otherwise Jedi is too
311311
# clever and uses the Python code instead of the signature object.
312312
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
313-
exec(code, locals())
314-
script = jedi.Interpreter('foo', [locals()])
313+
exec_locals = {}
314+
exec(code, exec_locals)
315+
script = jedi.Interpreter('foo', [exec_locals])
315316
c, = script.complete()
316317
sig, = c.get_signatures()
317318
a, b, c = sig.params
@@ -323,7 +324,7 @@ def test_completion_param_annotations():
323324
assert b.description == 'param b: str'
324325
assert c.description == 'param c: int=1.0'
325326

326-
d, = jedi.Interpreter('foo()', [locals()]).infer()
327+
d, = jedi.Interpreter('foo()', [exec_locals]).infer()
327328
assert d.name == 'bytes'
328329

329330

0 commit comments

Comments
 (0)