Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ jobs:
- 30.2
# - snapshot
python_version:
- 3.11
- 3.12
- 3.13
- 3.14
steps:
# Checkout
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
23 changes: 17 additions & 6 deletions elpy/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,20 +618,31 @@ def test_should_raise_fault(self):
class RPCGetCalltipTests(GenericRPCTests):
METHOD = "rpc_get_calltip"

def _assert_thread_calltip(self, actual):
"""Assert that a Thread calltip has the expected structure.

We check name and index exactly, and verify that all known-stable
params are present. Extra params (added in newer Python versions)
are allowed.
"""
self.assertEqual(actual['name'], 'Thread')
self.assertEqual(actual['index'], 0)
for param in self.THREAD_CALLTIP_REQUIRED_PARAMS:
self.assertIn(param, actual['params'])

def test_should_get_calltip(self):
expected = self.THREAD_CALLTIP
source, offset = source_and_offset(
"import threading\nthreading.Thread(_|_")
filename = self.project_file("test.py", source)
calltip = self.backend.rpc_get_calltip(filename,
source,
offset)
self.assertEqual(calltip, expected)
self._assert_thread_calltip(calltip)
calltip = self.backend.rpc_get_calltip_or_oneline_docstring(filename,
source,
offset)
calltip.pop('kind')
self.assertEqual(calltip, expected)
self._assert_thread_calltip(calltip)

def test_should_get_calltip_even_after_parens(self):
source, offset = source_and_offset(
Expand All @@ -640,12 +651,12 @@ def test_should_get_calltip_even_after_parens(self):
actual = self.backend.rpc_get_calltip(filename,
source,
offset)
self.assertEqual(self.THREAD_CALLTIP, actual)
self._assert_thread_calltip(actual)
actual = self.backend.rpc_get_calltip_or_oneline_docstring(filename,
source,
offset)
actual.pop('kind')
self.assertEqual(self.THREAD_CALLTIP, actual)
self._assert_thread_calltip(actual)

def test_should_get_calltip_at_closing_paren(self):
source, offset = source_and_offset(
Expand All @@ -654,7 +665,7 @@ def test_should_get_calltip_at_closing_paren(self):
actual = self.backend.rpc_get_calltip(filename,
source,
offset)
self.assertEqual(self.THREAD_CALLTIP, actual)
self._assert_thread_calltip(actual)
actual = self.backend.rpc_get_calltip_or_oneline_docstring(filename,
source,
offset)
Expand Down
55 changes: 29 additions & 26 deletions elpy/tests/test_jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ def __init__(self, *args, **kwargs):
' ``bytearray`` instance containing a JSON'
' document) to a Python object.'
)
if sys.version_info >= (3, 12):
self.JSON_DOCSTRING = (
"JSON (JavaScript Object Notation) <https://json.org>"
" is a subset of JavaScript syntax (ECMA-262"
" 3rd edition) used as a lightweight data interchange format.")
else:
self.JSON_DOCSTRING = (
"JSON (JavaScript Object Notation) <http://json.org>"
" is a subset of JavaScript syntax (ECMA-262"
" 3rd edition) used as a lightweight data interchange format.")
# The json module docstring URL changed from http to https in
# CPython 3.12, but jedi uses bundled typeshed stubs which may
# have either version regardless of runtime. We don't set
# JSON_DOCSTRING here; instead we override check_module_docstring.

def check_module_docstring(self, docstring):
# Accept either http or https since jedi's typeshed stubs may differ
self.assertIn("JSON (JavaScript Object Notation) <http", docstring['doc'])
self.assertIn("is a subset of JavaScript syntax (ECMA-262"
" 3rd edition) used as a lightweight data interchange format.",
docstring['doc'])

@mock.patch("elpy.jedibackend.run_with_debug")
def test_should_not_return_empty_docstring(self, run_with_debug):
Expand Down Expand Up @@ -171,23 +172,25 @@ class TestRPCGetCalltip(RPCGetCalltipTests,
'params': [u'a', u'b'],
'name': u'add'}
if jedibackend.JEDISUP19:
THREAD_CALLTIP = {'name': 'Thread',
'index': 0,
'params': ['group: None=None',
'target: Callable[..., object] | None=None',
'name: str | None=None',
'args: Iterable[Any]=()',
'kwargs: Mapping[str, Any] | None=None',
'daemon: bool | None=None']}
# Thread's calltip params vary by Python version (e.g., 3.14 added
# `context`) and by the typeshed stubs bundled with jedi. We only
# assert on the stable subset of params that have been present since
# Python 3.0 to avoid brittleness.
THREAD_CALLTIP_REQUIRED_PARAMS = [
'group: None=None',
'target: Callable[..., object] | None=None',
'name: str | None=None',
'args: Iterable[Any]=()',
'kwargs: Mapping[str, Any] | None=None',
'daemon: bool | None=None']
else:
THREAD_CALLTIP = {'name': 'Thread',
'index': 0,
'params': ['group: None=...',
'target: Optional[Callable[..., Any]]=...',
'name: Optional[str]=...',
'args: Iterable[Any]=...',
'kwargs: Mapping[str, Any]=...',
'daemon: Optional[bool]=...']}
THREAD_CALLTIP_REQUIRED_PARAMS = [
'group: None=...',
'target: Optional[Callable[..., Any]]=...',
'name: Optional[str]=...',
'args: Iterable[Any]=...',
'kwargs: Mapping[str, Any]=...',
'daemon: Optional[bool]=...']

def test_should_not_fail_with_get_subscope_by_name(self):
# Bug #677 / jedi#628
Expand Down
Loading