From fe0369436e465f03bac88ef9e90df64fdfec3395 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 29 Apr 2026 09:30:49 +0200 Subject: [PATCH] Change a few tests to match new typeshed --- test/completion/basic.py | 4 ++-- test/completion/named_param.py | 12 ++++++------ test/completion/pep0484_typing.py | 2 +- test/completion/stdlib.py | 2 +- test/test_api/test_classes.py | 6 +++--- test/test_api/test_full_name.py | 2 +- test/test_api/test_signatures.py | 2 +- test/test_inference/test_compiled.py | 2 +- test/test_inference/test_docstring.py | 2 +- test/test_inference/test_gradual/test_conversion.py | 12 ++++++------ test/test_utils.py | 8 ++++++-- 11 files changed, 29 insertions(+), 25 deletions(-) diff --git a/test/completion/basic.py b/test/completion/basic.py index 2894b0e8..e05c864f 100644 --- a/test/completion/basic.py +++ b/test/completion/basic.py @@ -233,12 +233,12 @@ def a(): # str literals in comment """ upper def completion_in_comment(): - #? ['Exception'] + #? ['Exception', 'ExceptionGroup'] # might fail because the comment is not a leaf: Exception pass some_word -#? ['Exception'] +#? ['Exception', 'ExceptionGroup'] # Very simple comment completion: Exception # Commment after it diff --git a/test/completion/named_param.py b/test/completion/named_param.py index de8073e9..ef659574 100644 --- a/test/completion/named_param.py +++ b/test/completion/named_param.py @@ -114,27 +114,27 @@ x(1, bar=2, ba) x(1, ba, baz=3) #? 14 ['baz='] x(1, bar=2, baz=3) -#? 7 ['BaseException'] +#? 7 ['BaseException', 'BaseExceptionGroup'] x(basee) #? 22 ['bar=', 'baz='] x(1, 2, 3, 4, 5, 6, bar=2) #? 14 ['baz='] y(1, bar=2, ba) -#? 7 ['bar=', 'BaseException', 'baz='] +#? 7 ['bar=', 'BaseException', 'BaseExceptionGroup', 'baz='] y(1, ba, baz=3) #? 14 ['baz='] y(1, bar=2, baz=3) -#? 7 ['BaseException'] +#? 7 ['BaseException', 'BaseExceptionGroup'] y(basee) -#? 22 ['bar=', 'BaseException', 'baz='] +#? 22 ['bar=', 'BaseException', 'BaseExceptionGroup', 'baz='] y(1, 2, 3, 4, 5, 6, bar=2) #? 11 ['bar=', 'bas='] z(bam=1, bar=2, bas=3) -#? 8 ['BaseException', 'bas='] +#? 8 ['BaseException', 'BaseExceptionGroup', 'bas='] z(1, bas=2) -#? 12 ['BaseException'] +#? 12 ['BaseException', 'BaseExceptionGroup'] z(1, bas=bas) #? 19 ['dict'] diff --git a/test/completion/pep0484_typing.py b/test/completion/pep0484_typing.py index 89c290ac..0bec7336 100644 --- a/test/completion/pep0484_typing.py +++ b/test/completion/pep0484_typing.py @@ -34,7 +34,7 @@ def we_can_has_sequence(p: Sequence[int], q: Sequence[B], r: Sequence[int], t[1] #? ["append"] u.a - #? float() list() + #? float() u[1.0] #? float() u[1] diff --git a/test/completion/stdlib.py b/test/completion/stdlib.py index 1686fa2c..1b65371a 100644 --- a/test/completion/stdlib.py +++ b/test/completion/stdlib.py @@ -360,7 +360,7 @@ X.attr_x.value X.attr_y.name #? float() X.attr_y.value -#? str() +#? X().name #? float() X().attr_x.attr_y.value diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index 01b7cf2d..acc3bc90 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -192,7 +192,7 @@ def test_hashlib_params(Script): script = Script('from hashlib import sha256') c, = script.complete() sig, = c.get_signatures() - assert [p.name for p in sig.params] == ['string'] + assert [p.name for p in sig.params] == ['data', 'usedforsecurity', 'string'] def test_signature_params(Script): @@ -465,7 +465,7 @@ def test_import(get_names): nms = nms[2].goto() assert nms assert all(n.type == 'module' for n in nms) - assert 'posixpath' in {n.name for n in nms} + assert 'path' in {n.name for n in nms} nms = get_names('import os.path', references=True) n = nms[0].goto()[0] @@ -616,7 +616,7 @@ def test_definition_goto_follow_imports(Script): ('n = next; n', 'Union[next(__i: Iterator[_T]) -> _T, ' 'next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]]'), - ('abs', 'abs(__x: SupportsAbs[_T]) -> _T'), + ('abs', 'abs(x: SupportsAbs[_T], /) -> _T'), ('def foo(x, y): return x if xxxx else y\nfoo(str(), 1)\nfoo', 'foo(x: str, y: int) -> Union[int, str]'), ('def foo(x, y = None): return x if xxxx else y\nfoo(str(), 1)\nfoo', diff --git a/test/test_api/test_full_name.py b/test/test_api/test_full_name.py index b8507cf6..2d8f996f 100644 --- a/test/test_api/test_full_name.py +++ b/test/test_api/test_full_name.py @@ -52,7 +52,7 @@ class TestFullNameWithGotoDefinitions(MixinTestFullName, TestCase): self.check(""" import re any_re = re.compile('.*') - any_re""", 'typing.Pattern') + any_re""", 're.Pattern') def test_from_import(self): self.check('from os import path', 'os.path') diff --git a/test/test_api/test_signatures.py b/test/test_api/test_signatures.py index a211c1e3..bf254185 100644 --- a/test/test_api/test_signatures.py +++ b/test/test_api/test_signatures.py @@ -68,4 +68,4 @@ def test_param_kind_and_name(code, index, param_code, kind, Script): def test_staticmethod(Script): s, = Script('staticmethod(').get_signatures() - assert s.to_string() == 'staticmethod(f: Callable[..., Any])' + assert s.to_string() == 'staticmethod(f: Callable[_P, _R_co], /)' diff --git a/test/test_inference/test_compiled.py b/test/test_inference/test_compiled.py index 611ff01d..f8763de2 100644 --- a/test/test_inference/test_compiled.py +++ b/test/test_inference/test_compiled.py @@ -86,7 +86,7 @@ def test_time_docstring(): import time comp, = jedi.Script('import time\ntime.sleep').complete() assert comp.docstring(raw=True) == time.sleep.__doc__ - expected = 'sleep(secs: float) -> None\n\n' + time.sleep.__doc__ + expected = 'sleep(seconds: _SupportsFloatOrIndex, /) -> None\n\n' + time.sleep.__doc__ assert comp.docstring() == expected diff --git a/test/test_inference/test_docstring.py b/test/test_inference/test_docstring.py index 6702617c..7720b450 100644 --- a/test/test_inference/test_docstring.py +++ b/test/test_inference/test_docstring.py @@ -60,7 +60,7 @@ def test_instance_doc(Script): '''Docstring of `TestClass`.''' tc = TestClass() tc""").infer() - assert defs[0].docstring() == 'Docstring of `TestClass`.' + assert defs[0].docstring() == 'TestClass()\n\nDocstring of `TestClass`.' def test_multiple_docstrings(Script): diff --git a/test/test_inference/test_gradual/test_conversion.py b/test/test_inference/test_gradual/test_conversion.py index ea9ea013..c0c08a10 100644 --- a/test/test_inference/test_gradual/test_conversion.py +++ b/test/test_inference/test_gradual/test_conversion.py @@ -10,20 +10,20 @@ def test_sqlite3_conversion(Script): script1 = Script('import sqlite3; sqlite3.Connection') d, = script1.infer() - assert not d.module_path + assert d.module_path assert d.full_name == 'sqlite3.Connection' assert convert_names([d._name], only_stubs=True) d, = script1.infer(only_stubs=True) assert d.is_stub() - assert d.full_name == 'sqlite3.dbapi2.Connection' + assert d.full_name == 'sqlite3.Connection' script2 = Script(path=d.module_path) d, = script2.infer(line=d.line, column=d.column) - assert not d.is_stub() + assert d.is_stub() assert d.full_name == 'sqlite3.Connection' v, = d._name.infer() - assert v.is_compiled() + assert not v.is_compiled() def test_conversion_of_stub_only(Script): @@ -70,11 +70,11 @@ def test_stub_get_line_code(Script): script = Script(code) d, = script.goto(only_stubs=True) # Replace \r for tests on Windows - assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta): ...\n' + assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta):\n' del parser_cache[script._inference_state.latest_grammar._hashed][d.module_path] d, = Script(path=d.module_path).goto(d.line, d.column, only_stubs=True) assert d.is_stub() - assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta): ...\n' + assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta):\n' def test_os_stat_result(Script): diff --git a/test/test_utils.py b/test/test_utils.py index 3000c2dc..368a57a1 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -36,7 +36,7 @@ class TestSetupReadline(unittest.TestCase): assert self.complete('list') == ['list'] assert self.complete('importerror') == ['ImportError'] s = "print(BaseE" - assert self.complete(s) == [s + 'xception'] + assert self.complete(s) == [s + 'xception', s + 'xceptionGroup'] def test_nested(self): assert self.complete('list.Insert') == ['list.insert'] @@ -69,7 +69,11 @@ class TestSetupReadline(unittest.TestCase): def test_import(self): s = 'from os.path import a' - assert set(self.complete(s)) == {s + 'ltsep', s + 'bspath'} + assert set(self.complete(s)) == { + s + 'ltsep', + s + 'bspath', + 'from os.path import ALLOW_MISSING' + } assert self.complete('import keyword') == ['import keyword'] import os