Skip to content

Commit 30af20a

Browse files
IanMatthewHuffIan Huff
andauthored
Nightly.variable and interactive window test fixes (#13272)
* variable and interactive window test fixes * review cleanup Co-authored-by: Ian Huff <[email protected]>
1 parent 047d667 commit 30af20a

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

news/3 Code Health/13269.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix failing interactive window and variable explorer tests.

pythonFiles/vscode_datascience_helpers/getJupyterVariableShape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Query Jupyter server for defined variables list
22
# Tested on 2.7 and 3.6
33
import json as _VSCODE_json
4-
import ast as _VSCODE_ast
54

65
# In IJupyterVariables.getValue this '_VSCode_JupyterTestValue' will be replaced with the json stringified value of the target variable
76
# Indexes off of _VSCODE_targetVariable need to index types that are part of IJupyterVariable
87
_VSCODE_targetVariable = _VSCODE_json.loads("""_VSCode_JupyterTestValue""")
98

10-
_VSCODE_evalResult = _VSCODE_ast.literal_eval(_VSCODE_targetVariable["name"])
9+
# Secure here as what we are doing an eval on is under our control
10+
_VSCODE_evalResult = eval(_VSCODE_targetVariable["name"]) # nosec
1111

1212
# Find shape and count if available
1313
if hasattr(_VSCODE_evalResult, "shape"):

src/client/datascience/raw-kernel/liveshare/hostRawNotebookProvider.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ import * as localize from '../../../common/utils/localize';
2323
import { noop } from '../../../common/utils/misc';
2424
import { IServiceContainer } from '../../../ioc/types';
2525
import { Identifiers, LiveShare, LiveShareCommands, Settings } from '../../constants';
26-
import { KernelSelector } from '../../jupyter/kernels/kernelSelector';
26+
import { KernelSelector, KernelSpecInterpreter } from '../../jupyter/kernels/kernelSelector';
2727
import { HostJupyterNotebook } from '../../jupyter/liveshare/hostJupyterNotebook';
2828
import { LiveShareParticipantHost } from '../../jupyter/liveshare/liveShareParticipantMixin';
2929
import { IRoleBasedObject } from '../../jupyter/liveshare/roleBasedFactory';
3030
import { IKernelLauncher } from '../../kernel-launcher/types';
3131
import { ProgressReporter } from '../../progress/progressReporter';
3232
import {
3333
IDataScienceFileSystem,
34-
IJupyterKernelSpec,
3534
INotebook,
3635
INotebookExecutionInfo,
3736
INotebookExecutionLogger,
@@ -168,7 +167,7 @@ export class HostRawNotebookProvider
168167
);
169168

170169
// Get the execution info for our notebook
171-
const info = await this.getExecutionInfo(kernelSpecInterpreter.kernelSpec);
170+
const info = await this.getExecutionInfo(kernelSpecInterpreter);
172171

173172
if (rawSession.isConnected) {
174173
// Create our notebook
@@ -213,12 +212,12 @@ export class HostRawNotebookProvider
213212
}
214213

215214
// Get the notebook execution info for this raw session instance
216-
private async getExecutionInfo(kernelSpec?: IJupyterKernelSpec): Promise<INotebookExecutionInfo> {
215+
private async getExecutionInfo(kernelSpecInterpreter: KernelSpecInterpreter): Promise<INotebookExecutionInfo> {
217216
return {
218217
connectionInfo: this.getConnection(),
219218
uri: Settings.JupyterServerLocalLaunch,
220-
interpreter: undefined,
221-
kernelSpec: kernelSpec,
219+
interpreter: kernelSpecInterpreter.interpreter,
220+
kernelSpec: kernelSpecInterpreter.kernelSpec,
222221
workingDir: await calculateWorkingDirectory(this.configService, this.workspaceService, this.fs),
223222
purpose: Identifiers.RawPurpose
224223
};

src/test/datascience/nativeEditor.functional.test.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,17 +2458,7 @@ df.head()`;
24582458
assert.ok(fileObject.cells[0].metadata.collapsed, 'Metadata erased during execution');
24592459

24602460
// Old language info should be changed by the new execution
2461-
if (!ioc.shouldMockJupyter) {
2462-
// For real jupyter raw kernel will use a default kernel without associated interpreter language_info
2463-
// so the execution should clear it out
2464-
assert.isUndefined(
2465-
fileObject.metadata.language_info,
2466-
'Old language info should be cleared out'
2467-
);
2468-
} else {
2469-
// In the mock case we return a mock kernelspec + interpreter language info, so it should be replaced
2470-
assert.notEqual(fileObject.metadata.language_info.version, '1.2.3');
2471-
}
2461+
assert.notEqual(fileObject.metadata.language_info.version, '1.2.3');
24722462

24732463
// Some tests don't have a kernelspec, in which case we should remove it
24742464
// If there is a spec, we should update the name and display name

0 commit comments

Comments
 (0)