Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add envFile's pythonpath before running tests #22269

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)),
};
eleanorjboyd marked this conversation as resolved.
Show resolved Hide resolved
// 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