Skip to content

Commit

Permalink
add envFile's pythonpath before running tests (#22269)
Browse files Browse the repository at this point in the history
fixes #22231

---------

Co-authored-by: Karthik Nadig <[email protected]>
  • Loading branch information
eleanorjboyd and karthiknadig authored Oct 20, 2023
1 parent 0438813 commit 6333752
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/client/testing/testController/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ export class PythonTestServer implements ITestServer, Disposable {
const { uuid } = options;
const isDiscovery = (testIds === undefined || testIds.length === 0) && runTestIdPort === undefined;
const mutableEnv = { ...env };
const pythonPathParts: string[] = process.env.PYTHONPATH?.split(path.delimiter) ?? [];
// get python path from mutable env, it contains process.env as well
const pythonPathParts: string[] = mutableEnv.PYTHONPATH?.split(path.delimiter) ?? [];
const pythonPathCommand = [options.cwd, ...pythonPathParts].join(path.delimiter);
mutableEnv.PYTHONPATH = pythonPathCommand;
mutableEnv.TEST_UUID = uuid.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
const mutableEnv = {
...(await this.envVarsService?.getEnvironmentVariables(uri)),
};
const pythonPathParts: string[] = process.env.PYTHONPATH?.split(path.delimiter) ?? [];
// get python path from mutable env, it contains process.env as well
const pythonPathParts: string[] = mutableEnv.PYTHONPATH?.split(path.delimiter) ?? [];
const pythonPathCommand = [fullPluginPath, ...pythonPathParts].join(path.delimiter);
mutableEnv.PYTHONPATH = pythonPathCommand;
mutableEnv.TEST_UUID = uuid.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
const { pytestArgs } = settings.testing;
const cwd = settings.testing.cwd && settings.testing.cwd.length > 0 ? settings.testing.cwd : uri.fsPath;
// get and edit env vars
const mutableEnv = { ...(await this.envVarsService?.getEnvironmentVariables(uri)) };
const pythonPathParts: string[] = process.env.PYTHONPATH?.split(path.delimiter) ?? [];
const mutableEnv = {
...(await this.envVarsService?.getEnvironmentVariables(uri)),
};
// get python path from mutable env, it contains process.env as well
const pythonPathParts: string[] = mutableEnv.PYTHONPATH?.split(path.delimiter) ?? [];
const pythonPathCommand = [fullPluginPath, ...pythonPathParts].join(path.delimiter);
mutableEnv.PYTHONPATH = pythonPathCommand;
mutableEnv.TEST_UUID = uuid.toString();
Expand Down

0 comments on commit 6333752

Please sign in to comment.