forked from VimPlug/jedi
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 https://github.com/davidhalter/jedi/issues/2002
This commit is contained in:
@@ -310,8 +310,9 @@ def test_completion_param_annotations():
|
|||||||
# Need to define this function not directly in Python. Otherwise Jedi is too
|
# Need to define this function not directly in Python. Otherwise Jedi is too
|
||||||
# clever and uses the Python code instead of the signature object.
|
# clever and uses the Python code instead of the signature object.
|
||||||
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
|
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
|
||||||
exec(code, locals())
|
exec_locals = {}
|
||||||
script = jedi.Interpreter('foo', [locals()])
|
exec(code, exec_locals)
|
||||||
|
script = jedi.Interpreter('foo', [exec_locals])
|
||||||
c, = script.complete()
|
c, = script.complete()
|
||||||
sig, = c.get_signatures()
|
sig, = c.get_signatures()
|
||||||
a, b, c = sig.params
|
a, b, c = sig.params
|
||||||
@@ -323,7 +324,7 @@ def test_completion_param_annotations():
|
|||||||
assert b.description == 'param b: str'
|
assert b.description == 'param b: str'
|
||||||
assert c.description == 'param c: int=1.0'
|
assert c.description == 'param c: int=1.0'
|
||||||
|
|
||||||
d, = jedi.Interpreter('foo()', [locals()]).infer()
|
d, = jedi.Interpreter('foo()', [exec_locals]).infer()
|
||||||
assert d.name == 'bytes'
|
assert d.name == 'bytes'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user