@@ -10,11 +10,7 @@ import { ICommandManager, IDocumentManager, IWorkspaceService } from '../../../c
10
10
import { IFileSystem , IPlatformService } from '../../../client/common/platform/types' ;
11
11
import { createCondaEnv } from '../../../client/common/process/pythonEnvironment' ;
12
12
import { createPythonProcessService } from '../../../client/common/process/pythonProcess' ;
13
- import {
14
- IProcessService ,
15
- IPythonExecutionFactory ,
16
- IPythonExecutionService ,
17
- } from '../../../client/common/process/types' ;
13
+ import { IProcessService , IPythonExecutionFactory } from '../../../client/common/process/types' ;
18
14
import {
19
15
ITerminalService ,
20
16
ITerminalServiceFactory ,
@@ -30,7 +26,6 @@ import { ICodeExecutionService } from '../../../client/terminals/types';
30
26
import { PYTHON_PATH } from '../../common' ;
31
27
import * as sinon from 'sinon' ;
32
28
import assert from 'assert' ;
33
- import { PythonExecInfo } from '../../../client/pythonEnvironments/exec' ;
34
29
35
30
suite ( 'Terminal - Code Execution' , ( ) => {
36
31
[ 'Terminal Execution' , 'Repl Execution' , 'Django Execution' ] . forEach ( ( testSuiteName ) => {
@@ -145,14 +140,7 @@ suite('Terminal - Code Execution', () => {
145
140
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => isWindows ) ;
146
141
platform . setup ( ( p ) => p . isMac ) . returns ( ( ) => isOsx ) ;
147
142
platform . setup ( ( p ) => p . isLinux ) . returns ( ( ) => isLinux ) ;
148
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
149
- pythonExecutionFactory
150
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
151
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
152
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
153
- executionService
154
- . setup ( ( e ) => e . getExecutionInfo ( ) )
155
- . returns ( ( ) => ( ( { command : PYTHON_PATH , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
143
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => PYTHON_PATH ) ;
156
144
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => [ ] ) ;
157
145
158
146
await executor . initializeRepl ( ) ;
@@ -185,14 +173,7 @@ suite('Terminal - Code Execution', () => {
185
173
workspace . setup ( ( w ) => w . rootPath ) . returns ( ( ) => path . join ( 'c:' , 'path' , 'to' ) ) ;
186
174
workspaceFolder . setup ( ( w ) => w . uri ) . returns ( ( ) => Uri . file ( path . join ( 'c:' , 'path' , 'to' ) ) ) ;
187
175
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => true ) ;
188
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
189
- pythonExecutionFactory
190
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
191
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
192
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
193
- executionService
194
- . setup ( ( e ) => e . getExecutionInfo ( ) )
195
- . returns ( ( ) => ( ( { command : PYTHON_PATH , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
176
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => PYTHON_PATH ) ;
196
177
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => [ ] ) ;
197
178
198
179
await executor . executeFile ( file ) ;
@@ -217,14 +198,7 @@ suite('Terminal - Code Execution', () => {
217
198
workspace . setup ( ( w ) => w . rootPath ) . returns ( ( ) => path . join ( 'c:' , 'path' , 'to' ) ) ;
218
199
workspaceFolder . setup ( ( w ) => w . uri ) . returns ( ( ) => Uri . file ( path . join ( 'c:' , 'path' , 'to' ) ) ) ;
219
200
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => true ) ;
220
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
221
- pythonExecutionFactory
222
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
223
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
224
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
225
- executionService
226
- . setup ( ( e ) => e . getExecutionInfo ( ) )
227
- . returns ( ( ) => ( ( { command : PYTHON_PATH , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
201
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => PYTHON_PATH ) ;
228
202
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => [ ] ) ;
229
203
230
204
await executor . executeFile ( file ) ;
@@ -240,14 +214,7 @@ suite('Terminal - Code Execution', () => {
240
214
workspace . setup ( ( w ) => w . getWorkspaceFolder ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => workspaceFolder . object ) ;
241
215
workspaceFolder . setup ( ( w ) => w . uri ) . returns ( ( ) => Uri . file ( path . join ( 'c' , 'path' , 'to' ) ) ) ;
242
216
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => false ) ;
243
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
244
- pythonExecutionFactory
245
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
246
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
247
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
248
- executionService
249
- . setup ( ( e ) => e . getExecutionInfo ( ) )
250
- . returns ( ( ) => ( ( { command : PYTHON_PATH , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
217
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => PYTHON_PATH ) ;
251
218
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => [ ] ) ;
252
219
253
220
await executor . executeFile ( file ) ;
@@ -271,14 +238,7 @@ suite('Terminal - Code Execution', () => {
271
238
workspace . setup ( ( w ) => w . getWorkspaceFolder ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => workspaceFolder . object ) ;
272
239
workspaceFolder . setup ( ( w ) => w . uri ) . returns ( ( ) => Uri . file ( path . join ( 'c' , 'path' , 'to' ) ) ) ;
273
240
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => isWindows ) ;
274
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
275
- pythonExecutionFactory
276
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
277
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
278
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
279
- executionService
280
- . setup ( ( e ) => e . getExecutionInfo ( ) )
281
- . returns ( ( ) => ( ( { command : PYTHON_PATH , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
241
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => PYTHON_PATH ) ;
282
242
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => [ ] ) ;
283
243
284
244
await executor . executeFile ( file ) ;
@@ -304,14 +264,7 @@ suite('Terminal - Code Execution', () => {
304
264
. setup ( ( w ) => w . uri )
305
265
. returns ( ( ) => Uri . file ( path . join ( 'c' , 'path' , 'to' , 'file with spaces in path' ) ) ) ;
306
266
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => isWindows ) ;
307
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
308
- pythonExecutionFactory
309
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
310
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
311
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
312
- executionService
313
- . setup ( ( e ) => e . getExecutionInfo ( ) )
314
- . returns ( ( ) => ( ( { command : PYTHON_PATH , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
267
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => PYTHON_PATH ) ;
315
268
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => [ ] ) ;
316
269
317
270
await executor . executeFile ( file ) ;
@@ -332,14 +285,7 @@ suite('Terminal - Code Execution', () => {
332
285
terminalSettings . setup ( ( t ) => t . executeInFileDir ) . returns ( ( ) => true ) ;
333
286
workspace . setup ( ( w ) => w . getWorkspaceFolder ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => undefined ) ;
334
287
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => isWindows ) ;
335
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
336
- pythonExecutionFactory
337
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
338
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
339
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
340
- executionService
341
- . setup ( ( e ) => e . getExecutionInfo ( ) )
342
- . returns ( ( ) => ( ( { command : PYTHON_PATH , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
288
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => PYTHON_PATH ) ;
343
289
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => [ ] ) ;
344
290
345
291
await executor . executeFile ( file ) ;
@@ -360,14 +306,7 @@ suite('Terminal - Code Execution', () => {
360
306
file : Uri ,
361
307
) : Promise < void > {
362
308
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => isWindows ) ;
363
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
364
- pythonExecutionFactory
365
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
366
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
367
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
368
- executionService
369
- . setup ( ( e ) => e . getExecutionInfo ( ) )
370
- . returns ( ( ) => ( ( { command : pythonPath , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
309
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
371
310
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => terminalArgs ) ;
372
311
terminalSettings . setup ( ( t ) => t . executeInFileDir ) . returns ( ( ) => false ) ;
373
312
workspace . setup ( ( w ) => w . getWorkspaceFolder ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => undefined ) ;
@@ -411,15 +350,7 @@ suite('Terminal - Code Execution', () => {
411
350
file : Uri ,
412
351
condaEnv : { name : string ; path : string } ,
413
352
) : Promise < void > {
414
- const condaRunArgs = 'conda run args' ;
415
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
416
- pythonExecutionFactory
417
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
418
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
419
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
420
- executionService
421
- . setup ( ( e ) => e . getExecutionInfo ( ) )
422
- . returns ( ( ) => ( ( { command : pythonPath , args : condaRunArgs } as unknown ) as PythonExecInfo ) ) ;
353
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
423
354
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => terminalArgs ) ;
424
355
terminalSettings . setup ( ( t ) => t . executeInFileDir ) . returns ( ( ) => false ) ;
425
356
workspace . setup ( ( w ) => w . getWorkspaceFolder ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => undefined ) ;
@@ -451,7 +382,7 @@ suite('Terminal - Code Execution', () => {
451
382
452
383
await executor . executeFile ( file ) ;
453
384
454
- const expectedArgs = [ ...condaRunArgs , ... terminalArgs , file . fsPath . fileToCommandArgument ( ) ] ;
385
+ const expectedArgs = [ ...terminalArgs , file . fsPath . fileToCommandArgument ( ) ] ;
455
386
456
387
terminalService . verify (
457
388
async ( t ) => t . sendCommand ( TypeMoq . It . isValue ( pythonPath ) , TypeMoq . It . isValue ( expectedArgs ) ) ,
@@ -485,14 +416,7 @@ suite('Terminal - Code Execution', () => {
485
416
. setup ( ( p ) => p . createCondaExecutionService ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
486
417
. returns ( ( ) => Promise . resolve ( undefined ) ) ;
487
418
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => isWindows ) ;
488
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
489
- pythonExecutionFactory
490
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
491
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
492
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
493
- executionService
494
- . setup ( ( e ) => e . getExecutionInfo ( ) )
495
- . returns ( ( ) => ( ( { command : pythonPath , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
419
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
496
420
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => terminalArgs ) ;
497
421
const expectedTerminalArgs = isDjangoRepl ? terminalArgs . concat ( [ 'manage.py' , 'shell' ] ) : terminalArgs ;
498
422
@@ -542,14 +466,7 @@ suite('Terminal - Code Execution', () => {
542
466
terminalArgs : string [ ] ,
543
467
condaEnv : { name : string ; path : string } ,
544
468
) {
545
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
546
- pythonExecutionFactory
547
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
548
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
549
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
550
- executionService
551
- . setup ( ( e ) => e . getExecutionInfo ( ) )
552
- . returns ( ( ) => ( ( { command : pythonPath , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
469
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
553
470
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => terminalArgs ) ;
554
471
555
472
const condaFile = 'conda' ;
@@ -619,14 +536,7 @@ suite('Terminal - Code Execution', () => {
619
536
const terminalArgs = [ '-a' , 'b' , 'c' ] ;
620
537
621
538
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => false ) ;
622
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
623
- pythonExecutionFactory
624
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
625
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
626
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
627
- executionService
628
- . setup ( ( e ) => e . getExecutionInfo ( ) )
629
- . returns ( ( ) => ( ( { command : pythonPath , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
539
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
630
540
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => terminalArgs ) ;
631
541
632
542
await executor . execute ( 'cmd1' ) ;
@@ -645,14 +555,7 @@ suite('Terminal - Code Execution', () => {
645
555
const pythonPath = 'usr/bin/python1234' ;
646
556
const terminalArgs = [ '-a' , 'b' , 'c' ] ;
647
557
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => false ) ;
648
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
649
- pythonExecutionFactory
650
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
651
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
652
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
653
- executionService
654
- . setup ( ( e ) => e . getExecutionInfo ( ) )
655
- . returns ( ( ) => ( ( { command : pythonPath , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
558
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
656
559
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => terminalArgs ) ;
657
560
658
561
let closeTerminalCallback : undefined | ( ( ) => void ) ;
@@ -699,14 +602,7 @@ suite('Terminal - Code Execution', () => {
699
602
const pythonPath = 'usr/bin/python1234' ;
700
603
const terminalArgs = [ '-a' , 'b' , 'c' ] ;
701
604
platform . setup ( ( p ) => p . isWindows ) . returns ( ( ) => false ) ;
702
- const executionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
703
- pythonExecutionFactory
704
- . setup ( ( p ) => p . create ( TypeMoq . It . isAny ( ) ) )
705
- . returns ( ( ) => Promise . resolve ( executionService . object ) ) ;
706
- executionService . setup ( ( p ) => ( p as any ) . then ) . returns ( ( ) => undefined ) ;
707
- executionService
708
- . setup ( ( e ) => e . getExecutionInfo ( ) )
709
- . returns ( ( ) => ( ( { command : pythonPath , args : [ ] } as unknown ) as PythonExecInfo ) ) ;
605
+ settings . setup ( ( s ) => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
710
606
terminalSettings . setup ( ( t ) => t . launchArgs ) . returns ( ( ) => terminalArgs ) ;
711
607
712
608
await executor . execute ( 'cmd1' ) ;
0 commit comments