@@ -3,17 +3,19 @@ import { CancellationToken, OutputChannel, Uri } from 'vscode';
33import  {  IPythonSettings ,  PythonSettings  }  from  '../../common/configSettings' ; 
44import  {  ErrorUtils  }  from  '../../common/errors/errorUtils' ; 
55import  {  ModuleNotInstalledError  }  from  '../../common/errors/moduleNotInstalledError' ; 
6+ import  {  IPythonToolExecutionService  }  from  '../../common/process/types' ; 
67import  { 
78 IProcessService , 
89 IPythonExecutionFactory , 
910 IPythonExecutionService , 
1011 ObservableExecutionResult , 
1112 SpawnOptions 
1213}  from  '../../common/process/types' ; 
14+ import  {  ExecutionInfo  }  from  '../../common/types' ; 
1315import  {  IEnvironmentVariablesProvider  }  from  '../../common/variables/types' ; 
1416import  {  IServiceContainer  }  from  '../../ioc/types' ; 
1517import  {  NOSETEST_PROVIDER ,  PYTEST_PROVIDER ,  UNITTEST_PROVIDER  }  from  './constants' ; 
16- import  {  TestProvider  }  from  './types' ; 
18+ import  {  ITestsHelper ,   TestProvider  }  from  './types' ; 
1719
1820export  type  Options  =  { 
1921 workspaceFolder : Uri ; 
@@ -36,21 +38,17 @@ export async function run(serviceContainer: IServiceContainer, testProvider: Tes
3638 // Unit tests have a special way of being executed 
3739 const  pythonServiceFactory  =  serviceContainer . get < IPythonExecutionFactory > ( IPythonExecutionFactory ) ; 
3840 pythonExecutionServicePromise  =  pythonServiceFactory . create ( options . workspaceFolder ) ; 
39-  promise  =  pythonExecutionServicePromise . then ( executionService  =>  { 
40-  return  executionService . execObservable ( options . args ,  {  ...spawnOptions  } ) ; 
41-  } ) ; 
42-  }  else  if  ( testExecutablePath )  { 
43-  const  processService  =  serviceContainer . get < IProcessService > ( IProcessService ) ; 
44-  const  envVarsService  =  serviceContainer . get < IEnvironmentVariablesProvider > ( IEnvironmentVariablesProvider ) ; 
45-  promise  =  envVarsService . getEnvironmentVariables ( options . workspaceFolder ) . then ( executionService  =>  { 
46-  return  processService . execObservable ( testExecutablePath ,  options . args ,  {  ...spawnOptions  } ) ; 
47-  } ) ; 
41+  promise  =  pythonExecutionServicePromise . then ( executionService  =>  executionService . execObservable ( options . args ,  {  ...spawnOptions  } ) ) ; 
4842 }  else  { 
49-  const  pythonServiceFactory  =  serviceContainer . get < IPythonExecutionFactory > ( IPythonExecutionFactory ) ; 
50-  pythonExecutionServicePromise  =  pythonServiceFactory . create ( options . workspaceFolder ) ; 
51-  promise  =  pythonExecutionServicePromise . then ( executionService  =>  { 
52-  return  executionService . execModuleObservable ( moduleName ,  options . args ,  {  ...spawnOptions  } ) ; 
53-  } ) ; 
43+  const  pythonToolsExecutionService  =  serviceContainer . get < IPythonToolExecutionService > ( IPythonToolExecutionService ) ; 
44+  const  testHelper  =  serviceContainer . get < ITestsHelper > ( ITestsHelper ) ; 
45+  const  executionInfo : ExecutionInfo  =  { 
46+  execPath : testExecutablePath , 
47+  args : options . args , 
48+  moduleName : testExecutablePath  &&  testExecutablePath . length  >  0  ? undefined  : moduleName , 
49+  product : testHelper . parseProduct ( testProvider ) 
50+  } ; 
51+  promise  =  pythonToolsExecutionService . execObservable ( executionInfo ,  spawnOptions ,  options . workspaceFolder ) ; 
5452 } 
5553
5654 return  promise . then ( result  =>  { 
0 commit comments