From 0c46b63d2c5db86aadd3a9e632194a9ad2b7faba Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Tue, 3 Sep 2024 14:21:43 -0700 Subject: [PATCH 1/2] fix django manage.py path validation (#24019) fixes https://github.com/microsoft/vscode-python/issues/24001 --- python_files/unittestadapter/django_handler.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/python_files/unittestadapter/django_handler.py b/python_files/unittestadapter/django_handler.py index dc520c13aff1..9daa816d0918 100644 --- a/python_files/unittestadapter/django_handler.py +++ b/python_files/unittestadapter/django_handler.py @@ -18,10 +18,8 @@ def django_discovery_runner(manage_py_path: str, args: List[str]) -> None: # Attempt a small amount of validation on the manage.py path. - try: - pathlib.Path(manage_py_path) - except Exception as e: - raise VSCodeUnittestError(f"Error running Django, manage.py path is not a valid path: {e}") # noqa: B904 + if not pathlib.Path(manage_py_path).exists(): + raise VSCodeUnittestError("Error running Django, manage.py path does not exist.") try: # Get path to the custom_test_runner.py parent folder, add to sys.path and new environment used for subprocess. @@ -61,10 +59,8 @@ def django_discovery_runner(manage_py_path: str, args: List[str]) -> None: def django_execution_runner(manage_py_path: str, test_ids: List[str], args: List[str]) -> None: # Attempt a small amount of validation on the manage.py path. - try: - pathlib.Path(manage_py_path) - except Exception as e: - raise VSCodeUnittestError(f"Error running Django, manage.py path is not a valid path: {e}") # noqa: B904 + if not pathlib.Path(manage_py_path).exists(): + raise VSCodeUnittestError("Error running Django, manage.py path does not exist.") try: # Get path to the custom_test_runner.py parent folder, add to sys.path. From 946ad9f8f0a284f40e4cf03470ec969c01177a6f Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Wed, 4 Sep 2024 11:48:31 -0700 Subject: [PATCH 2/2] Remove use of mocked output channel in virtual workspace (#24051) --- src/client/extensionInit.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/client/extensionInit.ts b/src/client/extensionInit.ts index 851bc943cb8d..38b402b3c9de 100644 --- a/src/client/extensionInit.ts +++ b/src/client/extensionInit.ts @@ -5,7 +5,6 @@ import { Container } from 'inversify'; import { Disposable, Memento, window } from 'vscode'; -import { instance, mock } from 'ts-mockito'; import { registerTypes as platformRegisterTypes } from './common/platform/serviceRegistry'; import { registerTypes as processRegisterTypes } from './common/process/serviceRegistry'; import { registerTypes as commonRegisterTypes } from './common/serviceRegistry'; @@ -29,7 +28,6 @@ import * as pythonEnvironments from './pythonEnvironments'; import { IDiscoveryAPI } from './pythonEnvironments/base/locator'; import { registerLogger } from './logging'; import { OutputChannelLogger } from './logging/outputChannelLogger'; -import { WorkspaceService } from './common/application/workspace'; // The code in this module should do nothing more complex than register // objects to DI and simple init (e.g. no side effects). That implies @@ -57,12 +55,7 @@ export function initializeGlobals( disposables.push(standardOutputChannel); disposables.push(registerLogger(new OutputChannelLogger(standardOutputChannel))); - const workspaceService = new WorkspaceService(); - const unitTestOutChannel = - workspaceService.isVirtualWorkspace || !workspaceService.isTrusted - ? // Do not create any test related output UI when using virtual workspaces. - instance(mock()) - : window.createOutputChannel(OutputChannelNames.pythonTest); + const unitTestOutChannel = window.createOutputChannel(OutputChannelNames.pythonTest); disposables.push(unitTestOutChannel); serviceManager.addSingletonInstance(ILogOutputChannel, standardOutputChannel);