From 435f644ede888731d53826aae33adfe0bb96dd3f Mon Sep 17 00:00:00 2001 From: "Eric N. Vander Weele" Date: Fri, 19 Nov 2021 16:35:23 -0500 Subject: [PATCH] Test that classes without arguments contain parentheses in signature Ensure consistency with function signatures that contain no arguments. --- tests/lsp_tests/test_completion.py | 40 +++++++++++++++++++ .../test_data/completion/completion_test2.py | 8 ++++ 2 files changed, 48 insertions(+) create mode 100644 tests/test_data/completion/completion_test2.py diff --git a/tests/lsp_tests/test_completion.py b/tests/lsp_tests/test_completion.py index 39ae45a..cca3835 100644 --- a/tests/lsp_tests/test_completion.py +++ b/tests/lsp_tests/test_completion.py @@ -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)) diff --git a/tests/test_data/completion/completion_test2.py b/tests/test_data/completion/completion_test2.py new file mode 100644 index 0000000..deb58ea --- /dev/null +++ b/tests/test_data/completion/completion_test2.py @@ -0,0 +1,8 @@ +"""Test file for test_completion.""" + + +class MyClass: + """Simple class.""" + + +MyC