@@ -179,7 +179,8 @@ export class DebugLauncher implements ITestDebugLauncher {
179
179
const [ program ] = args ;
180
180
configArgs . program = program ;
181
181
// 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 ) {
183
184
configArgs . module = 'pytest' ;
184
185
configArgs . program = undefined ;
185
186
}
@@ -203,7 +204,7 @@ export class DebugLauncher implements ITestDebugLauncher {
203
204
throw Error ( `Invalid debug config "${ debugConfig . name } "` ) ;
204
205
}
205
206
launchArgs . request = 'launch' ;
206
- if ( options . testProvider === 'pytest' ) {
207
+ if ( options . testProvider === 'pytest' && rewriteTestingEnabled ) {
207
208
if ( options . pytestPort && options . pytestUUID ) {
208
209
launchArgs . env = {
209
210
...launchArgs . env ,
@@ -227,14 +228,19 @@ export class DebugLauncher implements ITestDebugLauncher {
227
228
}
228
229
229
230
private static getTestLauncherScript ( testProvider : TestProvider ) {
231
+ const rewriteTestingEnabled = process . env . ENABLE_PYTHON_TESTING_REWRITE ;
230
232
switch ( testProvider ) {
231
233
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
234
238
}
235
239
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
238
244
}
239
245
default : {
240
246
throw new Error ( `Unknown test provider '${ testProvider } '` ) ;
0 commit comments