Skip to content

Commit

Permalink
add rewrite env var
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed May 12, 2023
1 parent c99e434 commit b42cc1c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"XVSC_PYTHON_LOG_TELEMETRY": "1",
// Enable this to log debugger output. Directory must exist ahead of time
"XDEBUGPY_LOG_DIR": "${workspaceRoot}/tmp/Debug_Output_Ex",
"ENABLE_PYTHON_TESTING_REWRITE": "1"
// "ENABLE_PYTHON_TESTING_REWRITE": "1"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion pythonFiles/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,3 @@ def post_response(cwd: str, session_node: TestNode) -> None:
f"Plugin!! error connection error[vscode-pytest]: {e}, port: {testPort}"
)
print(f"[vscode-pytest] data: {request}")
print(f"attempted port: {testPort}")
1 change: 0 additions & 1 deletion src/client/common/process/internal/scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export function execution_py_testlauncher(testArgs: string[]): string[] {
return [script, ...testArgs];
}

// execution.py
// eslint-disable-next-line camelcase
export function execution_pytest_testlauncher(testArgs: string[]): string[] {
// const script = path.join(SCRIPTS_DIR, 'unittestadapter', 'execution.py');
Expand Down
18 changes: 12 additions & 6 deletions src/client/testing/common/debugLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export class DebugLauncher implements ITestDebugLauncher {
const [program] = args;
configArgs.program = program;
// if the test provider is pytest, then use the pytest module instead of using a program
if (options.testProvider === 'pytest') {
const rewriteTestingEnabled = process.env.ENABLE_PYTHON_TESTING_REWRITE;
if (options.testProvider === 'pytest' && rewriteTestingEnabled) {
configArgs.module = 'pytest';
configArgs.program = undefined;
}
Expand All @@ -203,7 +204,7 @@ export class DebugLauncher implements ITestDebugLauncher {
throw Error(`Invalid debug config "${debugConfig.name}"`);
}
launchArgs.request = 'launch';
if (options.testProvider === 'pytest') {
if (options.testProvider === 'pytest' && rewriteTestingEnabled) {
if (options.pytestPort && options.pytestUUID) {
launchArgs.env = {
...launchArgs.env,
Expand All @@ -227,14 +228,19 @@ export class DebugLauncher implements ITestDebugLauncher {
}

private static getTestLauncherScript(testProvider: TestProvider) {
const rewriteTestingEnabled = process.env.ENABLE_PYTHON_TESTING_REWRITE;
switch (testProvider) {
case 'unittest': {
// return internalScripts.visualstudio_py_testlauncher; // old way unittest execution, debugger
return internalScripts.execution_py_testlauncher; // this is the new way to run unittest execution, debugger
if (rewriteTestingEnabled) {
return internalScripts.execution_py_testlauncher; // this is the new way to run unittest execution, debugger
}
return internalScripts.visualstudio_py_testlauncher; // old way unittest execution, debugger
}
case 'pytest': {
// return internalScripts.shell_exec;
return internalScripts.execution_pytest_testlauncher;
if (rewriteTestingEnabled) {
return internalScripts.execution_pytest_testlauncher; // this is the new way to run pytest execution, debugger
}
return internalScripts.testlauncher; // old way pytest execution, debugger
}
default: {
throw new Error(`Unknown test provider '${testProvider}'`);
Expand Down

0 comments on commit b42cc1c

Please sign in to comment.