Skip to content

Commit

Permalink
add cwd to python path during unittest sendCommand (#21490)
Browse files Browse the repository at this point in the history
fixes #21476
  • Loading branch information
eleanorjboyd authored Jun 26, 2023
1 parent 9c0af35 commit 304dffa
Show file tree
Hide file tree
Showing 2 changed files with 364 additions and 350 deletions.
6 changes: 5 additions & 1 deletion src/client/testing/testController/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as net from 'net';
import * as crypto from 'crypto';
import { Disposable, Event, EventEmitter } from 'vscode';
import * as path from 'path';
import {
ExecutionFactoryCreateWithEnvironmentOptions,
IPythonExecutionFactory,
Expand Down Expand Up @@ -141,12 +142,15 @@ export class PythonTestServer implements ITestServer, Disposable {

async sendCommand(options: TestCommandOptions, runTestIdPort?: string, callback?: () => void): Promise<void> {
const { uuid } = options;

const pythonPathParts: string[] = process.env.PYTHONPATH?.split(path.delimiter) ?? [];
const pythonPathCommand = [options.cwd, ...pythonPathParts].join(path.delimiter);
const spawnOptions: SpawnOptions = {
token: options.token,
cwd: options.cwd,
throwOnStdErr: true,
outputChannel: options.outChannel,
extraVariables: {},
extraVariables: { PYTHONPATH: pythonPathCommand },
};

if (spawnOptions.extraVariables) spawnOptions.extraVariables.RUN_TEST_IDS_PORT = runTestIdPort;
Expand Down
Loading

0 comments on commit 304dffa

Please sign in to comment.