@@ -8,6 +8,7 @@ import * as path from 'path';
88import { SemVer } from 'semver' ;
99import * as TypeMoq from 'typemoq' ;
1010import { Position , Range , Selection , TextDocument , TextEditor , TextLine , Uri } from 'vscode' ;
11+ import * as sinon from 'sinon' ;
1112import * as fs from '../../../client/common/platform/fs-paths' ;
1213import {
1314 IActiveResourceService ,
@@ -49,10 +50,11 @@ suite('Terminal - Code Execution Helper', () => {
4950 let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
5051 let configurationService : TypeMoq . IMock < IConfigurationService > ;
5152 let pythonSettings : TypeMoq . IMock < IPythonSettings > ;
53+ let jsonParseStub : sinon . SinonStub ;
5254 const workingPython : PythonEnvironment = {
5355 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' ,
5658 sysPrefix : 'Python' ,
5759 displayName : 'Python' ,
5860 envType : EnvironmentType . Unknown ,
@@ -134,7 +136,38 @@ suite('Terminal - Code Execution Helper', () => {
134136 editor . setup ( ( e ) => e . document ) . returns ( ( ) => document . object ) ;
135137 } ) ;
136138
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+
137169 test ( 'normalizeLines should call normalizeSelection.py' , async ( ) => {
170+ jsonParseStub . restore ( ) ;
138171 let execArgs = '' ;
139172
140173 processService
@@ -186,7 +219,7 @@ suite('Terminal - Code Execution Helper', () => {
186219 path . join ( TEST_FILES_PATH , `sample${ fileNameSuffix } _normalized_selection.py` ) ,
187220 'utf8' ,
188221 ) ;
189-
222+ // python3 -m pythonFiles.tests
190223 await ensureCodeIsNormalized ( code , expectedCode ) ;
191224 } ) ;
192225 } ) ;
0 commit comments