@@ -343,4 +343,52 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
343343 'Incorrect output'
344344 ) ;
345345 } ) ;
346+ test ( 'Verify escaping of output' , async ( ) => {
347+ await insertPythonCellAndWait ( '1' ) ;
348+ await insertPythonCellAndWait ( dedent `
349+ a="<a href=f>"
350+ a` ) ;
351+ await insertPythonCellAndWait ( dedent `
352+ a="<a href=f>"
353+ print(a)` ) ;
354+ await insertPythonCellAndWait ( 'raise Exception("<whatever>")' ) ;
355+ const cells = vscodeNotebook . activeNotebookEditor ?. document . cells ! ;
356+
357+ await executeActiveDocument ( ) ;
358+
359+ // Wait till execution count changes and status is error.
360+ await waitForCondition (
361+ async ( ) => assertHasExecutionCompletedWithErrors ( cells [ 3 ] ) ,
362+ 15_000 ,
363+ 'Cell did not get executed'
364+ ) ;
365+
366+ for ( const cell of cells ) {
367+ assert . lengthOf ( cell . outputs , 1 , 'Incorrect output' ) ;
368+ }
369+ assert . equal (
370+ cells [ 0 ] . outputs [ 0 ] . outputKind ,
371+ vscodeNotebookEnums . CellOutputKind . Rich ,
372+ 'Incorrect output for first cell'
373+ ) ;
374+ assert . equal (
375+ cells [ 1 ] . outputs [ 0 ] . outputKind ,
376+ vscodeNotebookEnums . CellOutputKind . Rich ,
377+ 'Incorrect output for first cell'
378+ ) ;
379+ assert . equal (
380+ cells [ 2 ] . outputs [ 0 ] . outputKind ,
381+ vscodeNotebookEnums . CellOutputKind . Rich ,
382+ 'Incorrect output for first cell'
383+ ) ;
384+ assertHasTextOutputInVSCode ( cells [ 0 ] , '1' ) ;
385+ assertHasTextOutputInVSCode ( cells [ 1 ] , '<a href=f>' , 0 , false ) ;
386+ assertHasTextOutputInVSCode ( cells [ 2 ] , '<a href=f>' , 0 , false ) ;
387+ const errorOutput = cells [ 3 ] . outputs [ 0 ] as CellErrorOutput ;
388+ assert . equal ( errorOutput . outputKind , vscodeNotebookEnums . CellOutputKind . Error , 'Incorrect output' ) ;
389+ assert . equal ( errorOutput . ename , 'Exception' , 'Incorrect ename' ) ; // As status contains ename, we don't want this displayed again.
390+ assert . equal ( errorOutput . evalue , '<whatever>' , 'Incorrect evalue' ) ; // As status contains ename, we don't want this displayed again.
391+ assert . isNotEmpty ( errorOutput . traceback , 'Incorrect traceback' ) ;
392+ assert . include ( errorOutput . traceback . join ( '' ) , '<whatever>' ) ;
393+ } ) ;
346394} ) ;
0 commit comments