Skip to content

Commit 145ccc8

Browse files
committed
fixes
1 parent 42cd011 commit 145ccc8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

python_files/vscode_pytest/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def pytest_exception_interact(node, call, report):
207207
send_execution_message(
208208
os.fsdecode(cwd),
209209
"success",
210-
collected_test if collected_test else None,
210+
collected_test or None,
211211
)
212212

213213

@@ -331,7 +331,7 @@ def pytest_report_teststatus(report, config): # noqa: ARG001
331331
send_execution_message(
332332
os.fsdecode(cwd),
333333
"success",
334-
collected_test if collected_test else None,
334+
collected_test or None,
335335
)
336336
yield
337337

@@ -365,7 +365,7 @@ def pytest_runtest_protocol(item, nextitem): # noqa: ARG001
365365
send_execution_message(
366366
os.fsdecode(cwd),
367367
"success",
368-
collected_test if collected_test else None,
368+
collected_test or None,
369369
)
370370
yield
371371

@@ -852,10 +852,7 @@ def create_session_node(session: pytest.Session) -> TestNode:
852852
session -- the pytest session.
853853
"""
854854
# Use PROJECT_ROOT_PATH if set (project-based testing), otherwise use session path (legacy)
855-
if PROJECT_ROOT_PATH:
856-
node_path = pathlib.Path(PROJECT_ROOT_PATH)
857-
else:
858-
node_path = get_node_path(session)
855+
node_path = pathlib.Path(PROJECT_ROOT_PATH) if PROJECT_ROOT_PATH else get_node_path(session)
859856
return {
860857
"name": node_path.name,
861858
"path": node_path,
@@ -1047,7 +1044,7 @@ def get_node_path(
10471044
except Exception as e:
10481045
raise VSCodePytestError(
10491046
f"Error occurred while calculating symlink equivalent from node path: {e}"
1050-
f"\n SYMLINK_PATH: {SYMLINK_PATH}, \n node path: {node_path}, \n cwd: {_CACHED_CWD if _CACHED_CWD else pathlib.Path.cwd()}"
1047+
f"\n SYMLINK_PATH: {SYMLINK_PATH}, \n node path: {node_path}, \n cwd: {_CACHED_CWD or pathlib.Path.cwd()}"
10511048
) from e
10521049
else:
10531050
result = node_path

src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ export function getNativePythonFinder(context?: IExtensionContext): NativePython
521521
},
522522
};
523523
}
524+
if (_finder && isFinderDisposed(_finder)) {
525+
_finder = undefined;
526+
}
524527
if (!_finder) {
525528
const cacheDirectory = context ? getCacheDirectory(context) : undefined;
526529
_finder = new NativePythonFinderImpl(cacheDirectory, context);
@@ -531,6 +534,10 @@ export function getNativePythonFinder(context?: IExtensionContext): NativePython
531534
return _finder;
532535
}
533536

537+
function isFinderDisposed(finder: NativePythonFinder): boolean {
538+
return 'isDisposed' in finder && Boolean((finder as { isDisposed?: boolean }).isDisposed);
539+
}
540+
534541
export function getCacheDirectory(context: IExtensionContext): Uri {
535542
return Uri.joinPath(context.globalStorageUri, 'pythonLocator');
536543
}

0 commit comments

Comments
 (0)