From 0cf576818227a546d4b3622962219531e5b350f2 Mon Sep 17 00:00:00 2001 From: jessienguyen2312 Date: Fri, 22 Sep 2023 15:35:25 -0400 Subject: [PATCH 1/2] Update test_code_actions.py --- src/test/python_tests/test_code_actions.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/python_tests/test_code_actions.py b/src/test/python_tests/test_code_actions.py index 29c8f98..21ce380 100644 --- a/src/test/python_tests/test_code_actions.py +++ b/src/test/python_tests/test_code_actions.py @@ -6,6 +6,8 @@ import os +from threading import Event + import pytest from hamcrest import assert_that, is_ @@ -14,6 +16,7 @@ TEST_FILE_PATH = constants.TEST_DATA / "sample1" / "sample.py" TEST_FILE_URI = utils.as_uri(str(TEST_FILE_PATH)) LINTER = utils.get_server_info_defaults()["name"] +TIMEOUT = 10 # 10 seconds @pytest.mark.parametrize( @@ -223,11 +226,22 @@ ) def test_command_code_action(code, contents, command): """Tests for code actions which run a command.""" + + actual = [] with utils.python_file(contents, TEST_FILE_PATH.parent) as temp_file: uri = utils.as_uri(os.fspath(temp_file)) with session.LspSession() as ls_session: ls_session.initialize() + done = Event() + + def _handler(params): + nonlocal actual + actual = params + done.set() + + ls_session.set_notification_callback(session.PUBLISH_DIAGNOSTICS, _handler) + ls_session.notify_did_open( { "textDocument": { @@ -239,6 +253,9 @@ def test_command_code_action(code, contents, command): } ) + # wait for some time to receive all notifications + done.wait(TIMEOUT) + diagnostics = [ { "range": { From 5f022a858c77932a77ea9136e85a01688c37a34a Mon Sep 17 00:00:00 2001 From: jessienguyen2312 Date: Fri, 22 Sep 2023 17:40:55 -0400 Subject: [PATCH 2/2] ran black ./src/test/python_tests and isort --profile black ./src/test/python_tests --- src/test/python_tests/test_code_actions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/python_tests/test_code_actions.py b/src/test/python_tests/test_code_actions.py index 21ce380..da90a68 100644 --- a/src/test/python_tests/test_code_actions.py +++ b/src/test/python_tests/test_code_actions.py @@ -5,7 +5,6 @@ """ import os - from threading import Event import pytest @@ -16,7 +15,7 @@ TEST_FILE_PATH = constants.TEST_DATA / "sample1" / "sample.py" TEST_FILE_URI = utils.as_uri(str(TEST_FILE_PATH)) LINTER = utils.get_server_info_defaults()["name"] -TIMEOUT = 10 # 10 seconds +TIMEOUT = 10 # 10 seconds @pytest.mark.parametrize(