Skip to content

Commit

Permalink
Merge pull request #182 from ericvw/ensure-class-parens
Browse files Browse the repository at this point in the history
Test that classes without arguments contain parentheses in signature
  • Loading branch information
pappasam authored Nov 22, 2021
2 parents cde429f + 435f644 commit 98a297c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/lsp_tests/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,43 @@ def test_lsp_completion_class_method() -> None:
],
}
assert_that(actual, is_(expected))


def test_lsp_completion_class_noargs() -> None:
"""Checks if classes without arguments include parenthesis in signature."""
with session.LspSession() as ls_session:
# Initialize, asking for eager resolution.
initialize_params = copy.deepcopy(VSCODE_DEFAULT_INITIALIZE)
initialize_params["initializationOptions"] = {
"completion": {"resolveEagerly": True}
}
ls_session.initialize(initialize_params)

uri = as_uri(COMPLETION_TEST_ROOT / "completion_test2.py")
actual = ls_session.text_document_completion(
{
"textDocument": {"uri": uri},
"position": {"line": 7, "character": 3},
"context": {"triggerKind": 1},
}
)

expected = {
"isIncomplete": False,
"items": [
{
"label": "MyClass",
"kind": 7,
"detail": "class MyClass()",
"documentation": {
"kind": "markdown",
"value": "```text\nSimple class.\n```",
},
"sortText": "z",
"filterText": "MyClass",
"insertText": "MyClass()$0",
"insertTextFormat": 2,
}
],
}
assert_that(actual, is_(expected))
8 changes: 8 additions & 0 deletions tests/test_data/completion/completion_test2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Test file for test_completion."""


class MyClass:
"""Simple class."""


MyC

0 comments on commit 98a297c

Please sign in to comment.