diff --git a/python_files/unittestadapter/execution.py b/python_files/unittestadapter/execution.py index bcac2779887e..5645241fb651 100644 --- a/python_files/unittestadapter/execution.py +++ b/python_files/unittestadapter/execution.py @@ -9,10 +9,18 @@ import socket import sys import traceback +import sysconfig import unittest from types import TracebackType from typing import Dict, List, Optional, Tuple, Type, Union +# Adds the scripts directory to the PATH as a workaround for enabling shell for test execution. +path_var_name = "PATH" if "PATH" in os.environ else "Path" +os.environ[path_var_name] = ( + sysconfig.get_paths()["scripts"] + os.pathsep + os.environ[path_var_name] +) + + script_dir = pathlib.Path(__file__).parent.parent sys.path.append(os.fspath(script_dir)) sys.path.insert(0, os.fspath(script_dir / "lib" / "python")) diff --git a/python_files/vscode_pytest/run_pytest_script.py b/python_files/vscode_pytest/run_pytest_script.py index cdf996e29ba2..fae9b5e4af18 100644 --- a/python_files/vscode_pytest/run_pytest_script.py +++ b/python_files/vscode_pytest/run_pytest_script.py @@ -5,9 +5,15 @@ import pathlib import socket import sys - +import sysconfig import pytest +# Adds the scripts directory to the PATH as a workaround for enabling shell for test execution. +path_var_name = "PATH" if "PATH" in os.environ else "Path" +os.environ[path_var_name] = ( + sysconfig.get_paths()["scripts"] + os.pathsep + os.environ[path_var_name] +) + script_dir = pathlib.Path(__file__).parent.parent sys.path.append(os.fspath(script_dir)) sys.path.append(os.fspath(script_dir / "lib" / "python"))