@@ -8,6 +8,7 @@ import * as path from 'path';
8
8
import { SemVer } from 'semver' ;
9
9
import * as TypeMoq from 'typemoq' ;
10
10
import { Position , Range , Selection , TextDocument , TextEditor , TextLine , Uri } from 'vscode' ;
11
+ import * as sinon from 'sinon' ;
11
12
import * as fs from '../../../client/common/platform/fs-paths' ;
12
13
import {
13
14
IActiveResourceService ,
@@ -49,10 +50,11 @@ suite('Terminal - Code Execution Helper', () => {
49
50
let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
50
51
let configurationService : TypeMoq . IMock < IConfigurationService > ;
51
52
let pythonSettings : TypeMoq . IMock < IPythonSettings > ;
53
+ let jsonParseStub : sinon . SinonStub ;
52
54
const workingPython : PythonEnvironment = {
53
55
path : PYTHON_PATH ,
54
- version : new SemVer ( '3.6.6-final ' ) ,
55
- sysVersion : '1.0.0 .0' ,
56
+ version : new SemVer ( '3.13.0 ' ) ,
57
+ sysVersion : '3.13 .0' ,
56
58
sysPrefix : 'Python' ,
57
59
displayName : 'Python' ,
58
60
envType : EnvironmentType . Unknown ,
@@ -134,7 +136,38 @@ suite('Terminal - Code Execution Helper', () => {
134
136
editor . setup ( ( e ) => e . document ) . returns ( ( ) => document . object ) ;
135
137
} ) ;
136
138
139
+ test ( 'normalizeLines should handle attach_bracket_paste correctly' , async ( ) => {
140
+ configurationService
141
+ . setup ( ( c ) => c . getSettings ( TypeMoq . It . isAny ( ) ) )
142
+ . returns ( {
143
+ REPL : {
144
+ EnableREPLSmartSend : false ,
145
+ REPLSmartSend : false ,
146
+ } ,
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
+ } as any ) ;
149
+ const actualProcessService = new ProcessService ( ) ;
150
+ processService
151
+ . setup ( ( p ) => p . execObservable ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
152
+ . returns ( ( file , args , options ) =>
153
+ actualProcessService . execObservable . apply ( actualProcessService , [ file , args , options ] ) ,
154
+ ) ;
155
+
156
+ jsonParseStub = sinon . stub ( JSON , 'parse' ) ;
157
+ const mockResult = {
158
+ normalized : 'print("Looks like you are on 3.13")' ,
159
+ attach_bracket_paste : true ,
160
+ } ;
161
+ jsonParseStub . returns ( mockResult ) ;
162
+
163
+ const result = await helper . normalizeLines ( 'print("Looks like you are on 3.13")' ) ;
164
+
165
+ expect ( result ) . to . equal ( `\u001b[200~print("Looks like you are on 3.13")\u001b[201~` ) ;
166
+ jsonParseStub . restore ( ) ;
167
+ } ) ;
168
+
137
169
test ( 'normalizeLines should call normalizeSelection.py' , async ( ) => {
170
+ jsonParseStub . restore ( ) ;
138
171
let execArgs = '' ;
139
172
140
173
processService
@@ -186,7 +219,7 @@ suite('Terminal - Code Execution Helper', () => {
186
219
path . join ( TEST_FILES_PATH , `sample${ fileNameSuffix } _normalized_selection.py` ) ,
187
220
'utf8' ,
188
221
) ;
189
-
222
+ // python3 -m pythonFiles.tests
190
223
await ensureCodeIsNormalized ( code , expectedCode ) ;
191
224
} ) ;
192
225
} ) ;
0 commit comments