From d3a68fc10f9af8ff15a013403aa27040a7a71bf8 Mon Sep 17 00:00:00 2001 From: Aaron Munger Date: Fri, 26 Jan 2024 14:41:02 -0800 Subject: [PATCH] ignore deprecation message causing exception (#15079) * ignore deprecation message causing exception * fix unit tests * more deprecation warning failures * do not fail for std err output --- ...DataViewerPythonInterpreter.vscode.test.ts | 2 +- .../plotViewer/plotViewer.vscode.test.ts | 11 ++++-- .../variableView/variableView.vscode.test.ts | 2 +- ...ndencyServiceInterpreter.node.unit.test.ts | 37 +++++-------------- ...DataViewerDependencyImplementation.node.ts | 5 +-- 5 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/test/datascience/data-viewing/showInDataViewerPythonInterpreter.vscode.test.ts b/src/test/datascience/data-viewing/showInDataViewerPythonInterpreter.vscode.test.ts index 7e57939a7b6..eecbbf4c2d3 100644 --- a/src/test/datascience/data-viewing/showInDataViewerPythonInterpreter.vscode.test.ts +++ b/src/test/datascience/data-viewing/showInDataViewerPythonInterpreter.vscode.test.ts @@ -58,7 +58,7 @@ suite('DataViewer @webview', function () { await vscode.commands.executeCommand('workbench.debug.viewlet.action.removeAllBreakpoints'); }); // Start debugging using the python extension - test.skip('Open from Python debug variables', async () => { + test('Open from Python debug variables', async () => { // First off, open up our python test file and make sure editor and groups are how we want them const textDocument = await openFile(testPythonFile); diff --git a/src/test/datascience/plotViewer/plotViewer.vscode.test.ts b/src/test/datascience/plotViewer/plotViewer.vscode.test.ts index 47b57132ee6..918a0766249 100644 --- a/src/test/datascience/plotViewer/plotViewer.vscode.test.ts +++ b/src/test/datascience/plotViewer/plotViewer.vscode.test.ts @@ -47,14 +47,17 @@ suite('VSCode Notebook PlotViewer integration - VSCode Notebook @webview', funct await insertCodeCell( `import numpy as np import pandas as pd -import matplotlib.pyplot as plt -x = np.linspace(0, 20, 100) +import matplotlib.pyplot as plt`, + { index: 1 } + ); + await insertCodeCell( + `x = np.linspace(0, 20, 100) plt.plot(x, np.sin(x)) plt.show()`, - { index: 0 } + { index: 1 } ); - const plotCell = window.activeNotebookEditor?.notebook.cellAt(0)!; + const plotCell = window.activeNotebookEditor?.notebook.cellAt(1)!; await runAllCellsInActiveNotebook(); await waitForExecutionCompletedSuccessfully(plotCell); diff --git a/src/test/datascience/variableView/variableView.vscode.test.ts b/src/test/datascience/variableView/variableView.vscode.test.ts index 42f6b34fb09..80c7f215e5d 100644 --- a/src/test/datascience/variableView/variableView.vscode.test.ts +++ b/src/test/datascience/variableView/variableView.vscode.test.ts @@ -272,7 +272,7 @@ mySet = {1, 2, 3} }); // Test opening data viewers while another dataviewer is open - test.skip('Open dataviewer', async function () { + test('Open dataviewer', async function () { // Send the command to open the view await commands.executeCommand(Commands.OpenVariableView); diff --git a/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts b/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts index a4cc7d9c312..4d766948ed6 100644 --- a/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts +++ b/src/webviews/extension-side/dataviewer/dataViewerDependencyServiceInterpreter.node.unit.test.ts @@ -16,6 +16,7 @@ import { pandasMinimumVersionSupportedByVariableViewer } from '../../../webviews import { PythonExecutionFactory } from '../../../platform/interpreter/pythonExecutionFactory.node'; import { IPythonExecutionFactory, IPythonExecutionService } from '../../../platform/interpreter/types.node'; import { mockedVSCodeNamespaces, resetVSCodeMocks } from '../../../test/vscode-mock'; +import { interpreterGetPandasVersion } from './interpreterDataViewerDependencyImplementation.node'; suite('DataViewerDependencyService (PythonEnvironment, Node)', () => { let dependencyService: DataViewerDependencyService; @@ -56,27 +57,15 @@ suite('DataViewerDependencyService (PythonEnvironment, Node)', () => { }); teardown(() => resetVSCodeMocks()); test('All ok, if pandas is installed and version is > 1.20', async () => { - when( - pythonExecService.exec( - deepEqual([ - '-c', - 'import pandas;print(pandas.__version__);print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d")' - ]), - anything() - ) - ).thenResolve({ stdout: '0.30.0\n5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d' }); + when(pythonExecService.exec(deepEqual(['-c', interpreterGetPandasVersion]), anything())).thenResolve({ + stdout: '0.30.0\n5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d' + }); await dependencyService.checkAndInstallMissingDependencies(interpreter); }); test('Throw exception if pandas is installed and version is = 0.20', async () => { - when( - pythonExecService.exec( - deepEqual([ - '-c', - 'import pandas;print(pandas.__version__);print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d")' - ]), - anything() - ) - ).thenResolve({ stdout: '0.20.0\n5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d' }); + when(pythonExecService.exec(deepEqual(['-c', interpreterGetPandasVersion]), anything())).thenResolve({ + stdout: '0.20.0\n5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d' + }); const promise = dependencyService.checkAndInstallMissingDependencies(interpreter); @@ -86,15 +75,9 @@ suite('DataViewerDependencyService (PythonEnvironment, Node)', () => { ); }); test('Throw exception if pandas is installed and version is < 0.20', async () => { - when( - pythonExecService.exec( - deepEqual([ - '-c', - 'import pandas;print(pandas.__version__);print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d")' - ]), - anything() - ) - ).thenResolve({ stdout: '0.10.0\n5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d' }); + when(pythonExecService.exec(deepEqual(['-c', interpreterGetPandasVersion]), anything())).thenResolve({ + stdout: '0.10.0\n5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d' + }); const promise = dependencyService.checkAndInstallMissingDependencies(interpreter); diff --git a/src/webviews/extension-side/dataviewer/interpreterDataViewerDependencyImplementation.node.ts b/src/webviews/extension-side/dataviewer/interpreterDataViewerDependencyImplementation.node.ts index 35d0725bab2..cc2a5aebee0 100644 --- a/src/webviews/extension-side/dataviewer/interpreterDataViewerDependencyImplementation.node.ts +++ b/src/webviews/extension-side/dataviewer/interpreterDataViewerDependencyImplementation.node.ts @@ -14,7 +14,7 @@ import { DataScience } from '../../../platform/common/utils/localize'; import { splitLines } from '../../../platform/common/helpers'; const separator = '5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d'; -export const kernelGetPandasVersion = `import pandas;print(pandas.__version__);print("${separator}")`; +export const interpreterGetPandasVersion = `import pandas;print(pandas.__version__);print("${separator}")`; /** * Uses the Python interpreter to manage dependencies of a Data Viewer. @@ -36,8 +36,7 @@ export class InterpreterDataViewerDependencyImplementation extends BaseDataViewe resource: undefined, interpreter }); - const result = await launcher.exec(['-c', kernelGetPandasVersion], { - throwOnStdErr: true, + const result = await launcher.exec(['-c', interpreterGetPandasVersion], { token }); const output = result.stdout;