Skip to content

Phase 2: Add missing test coverage before shared package extraction #458

@edvilme

Description

@edvilme

Phase 2: Test Coverage — Add missing tests before extraction

Part of the shared package extraction effort: microsoft/vscode-python-tools-extension-template#290

The following merged PRs introduced bug fixes or features that lack adequate test coverage. Tests should be added before extracting shared code into the monorepo package to ensure behavioral correctness is preserved.

PR Untested functionality description Missing tests
#327 Use global settings for ignorePatterns default The PR fixes _get_global_defaults() to read ignorePatterns from GLOBAL_SETTINGS instead of always defaulting to []. Tests test_ignore_patterns_match and test_ignore_patterns_no_match verify ignorePatterns filtering behavior via LSP initialization settings. However, they pass ignorePatterns explicitly in the initialization options rather than testing the GLOBAL_SETTINGS fallback path specifically, so the exact bug fix (reading from GLOBAL_SETTINGS when no workspace setting is present) may not be exercised.
#336 fix: Bug where successive python changed events trigger creating multiple servers The PR adds restart debouncing logic in extension.ts (isRestarting flag + timer), refactors python.ts event handling (checkAndFireEvent, refreshServerPython, sameInterpreter), and moves getInterpreterFromSetting to utilities.ts. TS tests cover getInterpreterDetails and getServerCwd but do NOT test the debouncing/throttling logic in extension.ts or the new event deduplication in python.ts.
#367 Update to Pygls 2 The Pygls 2 migration updated lsp_server.py API calls (get_document->get_text_document, publish_diagnostics->text_document_publish_diagnostics, show_message_log->window_log_message, etc.). Python tests exercise the LSP handlers (didOpen, didSave, didClose, codeAction) which use the updated APIs. However, the logging API changes (log_to_output, log_error, log_warning, log_always) and error notification paths aren't directly verified by tests.
#401 Sync with template: Fix duplicate server handlers on concurrent restarts The PR changes restartServer() in server.ts to move _disposables cleanup outside the lsClient guard, and wraps lsClient.stop() in deactivate() with try/catch. The existing server.unit.test.ts only tests getServerCwd, not restartServer() or the disposables cleanup logic. No tests cover the concurrent restart fix or deactivate error handling.
#428 Replace try-except-pass with contextlib.suppress Linting tests exercise lsp_utils._run_module and lsp_jsonrpc indirectly through the LSP server. However, the specific error-handling refactor (try/except:pass -> contextlib.suppress) is a behavioral no-op and not directly tested for exception suppression paths.
#434 Replace hand-rolled typings with @vscode/python-environments npm package TS tests cover getInterpreterDetails and interpreter resolution for both Python Environments and legacy extension. However, the specific API migration from hand-rolled typings to @vscode/python-environments npm package (e.g., PythonEnvironments.api() vs extensions.getExtension()) is not directly tested since the extension APIs are mocked.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions