@@ -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