From c2d03debf06db2446bc1fb4432d332e8a69a142b Mon Sep 17 00:00:00 2001 From: Wasim Lorgat Date: Wed, 15 Jan 2025 09:48:09 +0200 Subject: [PATCH] Wait longer to avoid flakiness (#6001) Quick fix for a flaky test introduced in #5950. --- .../positron_ipykernel/tests/test_positron_jedilsp.py | 6 ++++-- .../python_files/positron/positron_ipykernel/utils.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_positron_jedilsp.py b/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_positron_jedilsp.py index 8eb7f07b2a8..2bcab71215f 100644 --- a/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_positron_jedilsp.py +++ b/extensions/positron-python/python_files/positron/positron_ipykernel/tests/test_positron_jedilsp.py @@ -4,7 +4,7 @@ # import os -import time +from threading import Timer from typing import Any, Dict, List, Optional, cast from unittest.mock import Mock @@ -332,5 +332,7 @@ def test_close_notebook_cell_clears_diagnostics(): # Wait for the diagnostics to be published server.publish_diagnostics.assert_not_called() - time.sleep(0.06) + timers: List[Timer] = list(_clear_diagnostics_debounced.timers.values()) # type: ignore + for timer in timers: + timer.join() server.publish_diagnostics.assert_called_once_with(params.text_document.uri, []) diff --git a/extensions/positron-python/python_files/positron/positron_ipykernel/utils.py b/extensions/positron-python/python_files/positron/positron_ipykernel/utils.py index fbc51404dbd..5baeffa59c4 100644 --- a/extensions/positron-python/python_files/positron/positron_ipykernel/utils.py +++ b/extensions/positron-python/python_files/positron/positron_ipykernel/utils.py @@ -497,6 +497,9 @@ def run() -> None: # Store the interval on the debounced function; we lower the interval for faster tests. debounced.interval_s = interval_s # type: ignore + # Store timers on the debounced function; we wait for them to finish in tests. + debounced.timers = timers # type: ignore + return debounced return wrapper