Skip to content

Commit 2fb18e9

Browse files
committed
add rewrite env var
1 parent b8a439f commit 2fb18e9

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"XVSC_PYTHON_LOG_TELEMETRY": "1",
2424
// Enable this to log debugger output. Directory must exist ahead of time
2525
"XDEBUGPY_LOG_DIR": "${workspaceRoot}/tmp/Debug_Output_Ex",
26-
"ENABLE_PYTHON_TESTING_REWRITE": "1"
26+
// "ENABLE_PYTHON_TESTING_REWRITE": "1"
2727
}
2828
},
2929
{

pythonFiles/vscode_pytest/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,3 @@ def post_response(cwd: str, session_node: TestNode) -> None:
497497
f"Plugin!! error connection error[vscode-pytest]: {e}, port: {testPort}"
498498
)
499499
print(f"[vscode-pytest] data: {request}")
500-
print(f"attempted port: {testPort}")

src/client/common/process/internal/scripts/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export function execution_py_testlauncher(testArgs: string[]): string[] {
126126
return [script, ...testArgs];
127127
}
128128

129-
// execution.py
130129
// eslint-disable-next-line camelcase
131130
export function execution_pytest_testlauncher(testArgs: string[]): string[] {
132131
// const script = path.join(SCRIPTS_DIR, 'unittestadapter', 'execution.py');

src/client/testing/common/debugLauncher.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ export class DebugLauncher implements ITestDebugLauncher {
179179
const [program] = args;
180180
configArgs.program = program;
181181
// if the test provider is pytest, then use the pytest module instead of using a program
182-
if (options.testProvider === 'pytest') {
182+
const rewriteTestingEnabled = process.env.ENABLE_PYTHON_TESTING_REWRITE;
183+
if (options.testProvider === 'pytest' && rewriteTestingEnabled) {
183184
configArgs.module = 'pytest';
184185
configArgs.program = undefined;
185186
}
@@ -203,7 +204,7 @@ export class DebugLauncher implements ITestDebugLauncher {
203204
throw Error(`Invalid debug config "${debugConfig.name}"`);
204205
}
205206
launchArgs.request = 'launch';
206-
if (options.testProvider === 'pytest') {
207+
if (options.testProvider === 'pytest' && rewriteTestingEnabled) {
207208
if (options.pytestPort && options.pytestUUID) {
208209
launchArgs.env = {
209210
...launchArgs.env,
@@ -227,14 +228,19 @@ export class DebugLauncher implements ITestDebugLauncher {
227228
}
228229

229230
private static getTestLauncherScript(testProvider: TestProvider) {
231+
const rewriteTestingEnabled = process.env.ENABLE_PYTHON_TESTING_REWRITE;
230232
switch (testProvider) {
231233
case 'unittest': {
232-
// return internalScripts.visualstudio_py_testlauncher; // old way unittest execution, debugger
233-
return internalScripts.execution_py_testlauncher; // this is the new way to run unittest execution, debugger
234+
if (rewriteTestingEnabled) {
235+
return internalScripts.execution_py_testlauncher; // this is the new way to run unittest execution, debugger
236+
}
237+
return internalScripts.visualstudio_py_testlauncher; // old way unittest execution, debugger
234238
}
235239
case 'pytest': {
236-
// return internalScripts.shell_exec;
237-
return internalScripts.execution_pytest_testlauncher;
240+
if (rewriteTestingEnabled) {
241+
return internalScripts.execution_pytest_testlauncher; // this is the new way to run pytest execution, debugger
242+
}
243+
return internalScripts.testlauncher; // old way pytest execution, debugger
238244
}
239245
default: {
240246
throw new Error(`Unknown test provider '${testProvider}'`);

0 commit comments

Comments
 (0)