mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-25 17:58:35 +08:00
Fix signature tests
This commit is contained in:
@@ -1,15 +1,25 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
from operator import ge, le
|
||||||
|
|
||||||
from jedi.evaluate.gradual.conversion import stub_to_actual_context_set
|
from jedi.evaluate.gradual.conversion import stub_to_actual_context_set
|
||||||
|
|
||||||
|
|
||||||
def test_compiled_signature(Script):
|
@pytest.mark.parametrize(
|
||||||
code = 'import math; math.cos'
|
'code, sig, names, op, version', [
|
||||||
sig = 'cos(x, /)'
|
('import math; math.cos', 'cos(x)', ['x'], le, (3, 6)),
|
||||||
|
('import math; math.cos', 'cos(x, /)', ['x'], ge, (3, 7)),
|
||||||
|
|
||||||
|
('next', 'next(iterator, default=None)', ['iterator', 'default'], ge, (2, 7)),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_compiled_signature(Script, environment, code, sig, names, op, version):
|
||||||
|
if not op(environment.version_info, version):
|
||||||
|
pytest.skip("Not running for this version")
|
||||||
|
|
||||||
d, = Script(code).goto_definitions()
|
d, = Script(code).goto_definitions()
|
||||||
context, = d._name.infer()
|
context, = d._name.infer()
|
||||||
compiled, = stub_to_actual_context_set(context)
|
compiled, = stub_to_actual_context_set(context)
|
||||||
signature, = compiled.get_signatures()
|
signature, = compiled.get_signatures()
|
||||||
assert signature.to_string() == sig
|
assert signature.to_string() == sig
|
||||||
assert signature.get_param_names() == []
|
assert [n.string_name for n in signature.get_param_names()] == names
|
||||||
assert signature.annotation is None
|
assert signature.annotation is None
|
||||||
|
|||||||
Reference in New Issue
Block a user