Skip to content

Commit 312d9ef

Browse files
authored
add sys config scripts path to test execution path (#23418)
resolves #22395
1 parent a91346b commit 312d9ef

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Diff for: python_files/unittestadapter/execution.py

+8
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@
99
import socket
1010
import sys
1111
import traceback
12+
import sysconfig
1213
import unittest
1314
from types import TracebackType
1415
from typing import Dict, List, Optional, Tuple, Type, Union
1516

17+
# Adds the scripts directory to the PATH as a workaround for enabling shell for test execution.
18+
path_var_name = "PATH" if "PATH" in os.environ else "Path"
19+
os.environ[path_var_name] = (
20+
sysconfig.get_paths()["scripts"] + os.pathsep + os.environ[path_var_name]
21+
)
22+
23+
1624
script_dir = pathlib.Path(__file__).parent.parent
1725
sys.path.append(os.fspath(script_dir))
1826
sys.path.insert(0, os.fspath(script_dir / "lib" / "python"))

Diff for: python_files/vscode_pytest/run_pytest_script.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
import pathlib
66
import socket
77
import sys
8-
8+
import sysconfig
99
import pytest
1010

11+
# Adds the scripts directory to the PATH as a workaround for enabling shell for test execution.
12+
path_var_name = "PATH" if "PATH" in os.environ else "Path"
13+
os.environ[path_var_name] = (
14+
sysconfig.get_paths()["scripts"] + os.pathsep + os.environ[path_var_name]
15+
)
16+
1117
script_dir = pathlib.Path(__file__).parent.parent
1218
sys.path.append(os.fspath(script_dir))
1319
sys.path.append(os.fspath(script_dir / "lib" / "python"))

0 commit comments

Comments
 (0)