@@ -10,6 +10,7 @@ import { SemVer } from 'semver';
10
10
import * as TypeMoq from 'typemoq' ;
11
11
import { Position , Range , Selection , TextDocument , TextEditor , TextLine , Uri } from 'vscode' ;
12
12
import {
13
+ IActiveResourceService ,
13
14
IApplicationShell ,
14
15
ICommandManager ,
15
16
IDocumentManager ,
@@ -23,6 +24,7 @@ import {
23
24
IProcessServiceFactory ,
24
25
ObservableExecutionResult ,
25
26
} from '../../../client/common/process/types' ;
27
+ import { IConfigurationService , IPythonSettings } from '../../../client/common/types' ;
26
28
import { Architecture } from '../../../client/common/utils/platform' ;
27
29
import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types' ;
28
30
import { IInterpreterService } from '../../../client/interpreter/contracts' ;
@@ -35,6 +37,7 @@ import { PYTHON_PATH } from '../../common';
35
37
const TEST_FILES_PATH = path . join ( EXTENSION_ROOT_DIR , 'src' , 'test' , 'python_files' , 'terminalExec' ) ;
36
38
37
39
suite ( 'Terminal - Code Execution Helper' , ( ) => {
40
+ let activeResourceService : TypeMoq . IMock < IActiveResourceService > ;
38
41
let documentManager : TypeMoq . IMock < IDocumentManager > ;
39
42
let applicationShell : TypeMoq . IMock < IApplicationShell > ;
40
43
let helper : ICodeExecutionHelper ;
@@ -44,6 +47,8 @@ suite('Terminal - Code Execution Helper', () => {
44
47
let interpreterService : TypeMoq . IMock < IInterpreterService > ;
45
48
let commandManager : TypeMoq . IMock < ICommandManager > ;
46
49
let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
50
+ let configurationService : TypeMoq . IMock < IConfigurationService > ;
51
+ let pythonSettings : TypeMoq . IMock < IPythonSettings > ;
47
52
const workingPython : PythonEnvironment = {
48
53
path : PYTHON_PATH ,
49
54
version : new SemVer ( '3.6.6-final' ) ,
@@ -57,13 +62,16 @@ suite('Terminal - Code Execution Helper', () => {
57
62
setup ( ( ) => {
58
63
const serviceContainer = TypeMoq . Mock . ofType < IServiceContainer > ( ) ;
59
64
commandManager = TypeMoq . Mock . ofType < ICommandManager > ( ) ;
65
+ configurationService = TypeMoq . Mock . ofType < IConfigurationService > ( ) ;
60
66
workspaceService = TypeMoq . Mock . ofType < IWorkspaceService > ( ) ;
61
67
documentManager = TypeMoq . Mock . ofType < IDocumentManager > ( ) ;
62
68
applicationShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
63
69
const envVariablesProvider = TypeMoq . Mock . ofType < IEnvironmentVariablesProvider > ( ) ;
64
70
processService = TypeMoq . Mock . ofType < IProcessService > ( ) ;
65
71
interpreterService = TypeMoq . Mock . ofType < IInterpreterService > ( ) ;
66
-
72
+ activeResourceService = TypeMoq . Mock . ofType < IActiveResourceService > ( ) ;
73
+ pythonSettings = TypeMoq . Mock . ofType < IPythonSettings > ( ) ;
74
+ const resource = Uri . parse ( 'a' ) ;
67
75
// eslint-disable-next-line @typescript-eslint/no-explicit-any
68
76
processService . setup ( ( x : any ) => x . then ) . returns ( ( ) => undefined ) ;
69
77
interpreterService
@@ -95,6 +103,24 @@ suite('Terminal - Code Execution Helper', () => {
95
103
serviceContainer
96
104
. setup ( ( c ) => c . get ( TypeMoq . It . isValue ( IEnvironmentVariablesProvider ) , TypeMoq . It . isAny ( ) ) )
97
105
. returns ( ( ) => envVariablesProvider . object ) ;
106
+ serviceContainer
107
+ . setup ( ( c ) => c . get ( TypeMoq . It . isValue ( IConfigurationService ) ) )
108
+ . returns ( ( ) => configurationService . object ) ;
109
+ serviceContainer
110
+ . setup ( ( c ) => c . get ( TypeMoq . It . isValue ( IActiveResourceService ) ) )
111
+ . returns ( ( ) => activeResourceService . object ) ;
112
+ activeResourceService . setup ( ( a ) => a . getActiveResource ( ) ) . returns ( ( ) => resource ) ;
113
+ pythonSettings . setup ( ( s ) => s . REPL ) . returns ( ( ) => ( { enableREPLSmartSend : false , REPLSmartSend : false } ) ) ;
114
+ configurationService . setup ( ( x ) => x . getSettings ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => pythonSettings . object ) ;
115
+ configurationService
116
+ . setup ( ( c ) => c . getSettings ( TypeMoq . It . isAny ( ) ) )
117
+ . returns ( {
118
+ REPL : {
119
+ EnableREPLSmartSend : false ,
120
+ REPLSmartSend : false ,
121
+ } ,
122
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
+ } as any ) ;
98
124
helper = new CodeExecutionHelper ( serviceContainer . object ) ;
99
125
100
126
document = TypeMoq . Mock . ofType < TextDocument > ( ) ;
@@ -118,6 +144,15 @@ suite('Terminal - Code Execution Helper', () => {
118
144
} ) ;
119
145
120
146
async function ensureCodeIsNormalized ( source : string , expectedSource : string ) {
147
+ configurationService
148
+ . setup ( ( c ) => c . getSettings ( TypeMoq . It . isAny ( ) ) )
149
+ . returns ( {
150
+ REPL : {
151
+ EnableREPLSmartSend : false ,
152
+ REPLSmartSend : false ,
153
+ } ,
154
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
155
+ } as any ) ;
121
156
const actualProcessService = new ProcessService ( ) ;
122
157
processService
123
158
. setup ( ( p ) => p . execObservable ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
@@ -131,6 +166,15 @@ suite('Terminal - Code Execution Helper', () => {
131
166
132
167
[ '' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' ] . forEach ( ( fileNameSuffix ) => {
133
168
test ( `Ensure code is normalized (Sample${ fileNameSuffix } )` , async ( ) => {
169
+ configurationService
170
+ . setup ( ( c ) => c . getSettings ( TypeMoq . It . isAny ( ) ) )
171
+ . returns ( {
172
+ REPL : {
173
+ EnableREPLSmartSend : false ,
174
+ REPLSmartSend : false ,
175
+ } ,
176
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
+ } as any ) ;
134
178
const code = await fs . readFile ( path . join ( TEST_FILES_PATH , `sample${ fileNameSuffix } _raw.py` ) , 'utf8' ) ;
135
179
const expectedCode = await fs . readFile (
136
180
path . join ( TEST_FILES_PATH , `sample${ fileNameSuffix } _normalized_selection.py` ) ,
0 commit comments