Skip to content

Commit

Permalink
add sys config scripts path to test execution path (#23418)
Browse files Browse the repository at this point in the history
resolves #22395
  • Loading branch information
eleanorjboyd authored May 14, 2024
1 parent a91346b commit 312d9ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions python_files/unittestadapter/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
8 changes: 7 additions & 1 deletion python_files/vscode_pytest/run_pytest_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 312d9ef

Please sign in to comment.