Some more signature tests

This commit is contained in:
Dave Halter
2019-05-22 00:51:52 +02:00
parent f46d676130
commit b1e6901d61
2 changed files with 6 additions and 3 deletions

View File

@@ -134,7 +134,7 @@ class CompiledObject(Context):
return self.access_handle.get_signature_text() return self.access_handle.get_signature_text()
except ValueError: except ValueError:
params_str, ret = self._parse_function_doc() params_str, ret = self._parse_function_doc()
return '(' + params_str + ')' + ret return '(' + params_str + ')' + (ret and ' -> ' + ret)
def get_signatures(self): def get_signatures(self):
return [BuiltinSignature(self)] return [BuiltinSignature(self)]

View File

@@ -1,15 +1,18 @@
import pytest import pytest
from operator import ge, le from operator import ge, lt
from jedi.evaluate.gradual.conversion import stub_to_actual_context_set from jedi.evaluate.gradual.conversion import stub_to_actual_context_set
@pytest.mark.parametrize( @pytest.mark.parametrize(
'code, sig, names, op, version', [ 'code, sig, names, op, version', [
('import math; math.cos', 'cos(x)', ['x'], le, (3, 6)), ('import math; math.cos', 'cos(x)', ['x'], lt, (3, 7)),
('import math; math.cos', 'cos(x, /)', ['x'], ge, (3, 7)), ('import math; math.cos', 'cos(x, /)', ['x'], ge, (3, 7)),
('next', 'next(iterator, default=None)', ['iterator', 'default'], ge, (2, 7)), ('next', 'next(iterator, default=None)', ['iterator', 'default'], ge, (2, 7)),
('pow', 'pow(x, y, z=None) -> number', ['x', 'y', 'z'], lt, (3, 5)),
('pow', 'pow(x, y, z=None, /)', ['x', 'y', 'z'], ge, (3, 5)),
] ]
) )
def test_compiled_signature(Script, environment, code, sig, names, op, version): def test_compiled_signature(Script, environment, code, sig, names, op, version):