Skip to content

Commit 091b0ea

Browse files
committed
Fixes to tests
1 parent 43c7f0b commit 091b0ea

File tree

6 files changed

+81
-244
lines changed

6 files changed

+81
-244
lines changed

src/client/datascience/jupyter/kernels/cellExecution.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ export class CellExecution {
123123
this.started = true;
124124
// Ensure we clear the cell state and trigger a change.
125125
clearCellForExecution(this.cell);
126-
this.cell.metadata.runStartTime = new Date().getTime();
126+
new WorkspaceEdit().replaceCellMetadata(this.cell.notebook.uri, this.cell.notebook.cells.indexOf(this.cell), {
127+
...this.cell.metadata,
128+
runStartTime: new Date().getTime()
129+
});
127130
this.stopWatch.reset();
128131
// Changes to metadata must be saved in ipynb, hence mark doc has dirty.
129132
this.contentProvider.notifyChangesToDocument(this.cell.notebook);
@@ -158,7 +161,10 @@ export class CellExecution {
158161

159162
private completedWithErrors(error: Partial<Error>) {
160163
this.sendPerceivedCellExecute();
161-
this.cell.metadata.lastRunDuration = this.stopWatch.elapsedTime;
164+
new WorkspaceEdit().replaceCellMetadata(this.cell.notebook.uri, this.cell.notebook.cells.indexOf(this.cell), {
165+
...this.cell.metadata,
166+
lastRunDuration: this.stopWatch.elapsedTime
167+
});
162168
updateCellWithErrorStatus(this.cell, error);
163169
this.contentProvider.notifyChangesToDocument(this.cell.notebook);
164170
this.errorHandler.handleError((error as unknown) as Error).ignoreErrors();

src/test/datascience/notebook/edit.ds.test.ts

Lines changed: 0 additions & 173 deletions
This file was deleted.

src/test/datascience/notebook/executionService.ds.test.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
5757
setup(deleteAllCellsAndWait);
5858
suiteTeardown(() => closeNotebooksAndCleanUpAfterTests(disposables));
5959
test('Execute cell using VSCode Kernel', async () => {
60-
await insertPythonCellAndWait('print("Hello World")', 0);
60+
await insertPythonCellAndWait('print("Hello World")');
6161
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
6262

6363
await executeCell(cell);
@@ -70,7 +70,7 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
7070
);
7171
});
7272
test('Executed events are triggered', async () => {
73-
await insertPythonCellAndWait('print("Hello World")', 0);
73+
await insertPythonCellAndWait('print("Hello World")');
7474
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
7575

7676
const executed = createEventHandler(editorProvider.activeEditor!, 'executed', disposables);
@@ -88,7 +88,7 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
8888
await codeExecuted.assertFired(1_000);
8989
});
9090
test('Empty cell will not get executed', async () => {
91-
await insertPythonCellAndWait('', 0);
91+
await insertPythonCellAndWait('');
9292
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
9393
await executeCell(cell);
9494

@@ -97,8 +97,8 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
9797
assert.isUndefined(cell?.metadata.runState);
9898
});
9999
test('Empty cells will not get executed when running whole document', async () => {
100-
await insertPythonCellAndWait('', 0);
101-
await insertPythonCellAndWait('print("Hello World")', 1);
100+
await insertPythonCellAndWait('');
101+
await insertPythonCellAndWait('print("Hello World")');
102102
const cells = vscodeNotebook.activeNotebookEditor?.document.cells!;
103103

104104
await executeActiveDocument();
@@ -112,7 +112,7 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
112112
assert.isUndefined(cells[0].metadata.runState);
113113
});
114114
test('Execute cell should mark a notebook as being dirty', async () => {
115-
await insertPythonCellAndWait('print("Hello World")', 0);
115+
await insertPythonCellAndWait('print("Hello World")');
116116
const contentProvider = api.serviceContainer.get<INotebookContentProvider>(INotebookContentProvider);
117117
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
118118
const changedEvent = createEventHandler(contentProvider, 'onDidChangeNotebook', disposables);
@@ -128,7 +128,7 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
128128
assert.ok(changedEvent.fired, 'Notebook should be dirty after executing a cell');
129129
});
130130
test('Verify Cell output, execution count and status', async () => {
131-
await insertPythonCellAndWait('print("Hello World")', 0);
131+
await insertPythonCellAndWait('print("Hello World")');
132132
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
133133

134134
await executeActiveDocument();
@@ -147,8 +147,8 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
147147
assert.ok(cell.metadata.executionOrder, 'Execution count should be > 0');
148148
});
149149
test('Verify multiple cells get executed', async () => {
150-
await insertPythonCellAndWait('print("Foo Bar")', 0);
151-
await insertPythonCellAndWait('print("Hello World")', 1);
150+
await insertPythonCellAndWait('print("Foo Bar")');
151+
await insertPythonCellAndWait('print("Hello World")');
152152
const cells = vscodeNotebook.activeNotebookEditor?.document.cells!;
153153

154154
await executeActiveDocument();
@@ -163,14 +163,14 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
163163

164164
// Verify output.
165165
assertHasTextOutputInVSCode(cells[0], 'Foo Bar', 0);
166-
assertHasTextOutputInVSCode(cells[1], 'Hello World', 0);
166+
assertHasTextOutputInVSCode(cells[1], 'Hello World', 1);
167167

168168
// Verify execution count.
169169
assert.ok(cells[0].metadata.executionOrder, 'Execution count should be > 0');
170170
assert.equal(cells[1].metadata.executionOrder! - 1, cells[0].metadata.executionOrder!);
171171
});
172172
test('Verify metadata for successfully executed cell', async () => {
173-
await insertPythonCellAndWait('print("Foo Bar")', 0);
173+
await insertPythonCellAndWait('print("Foo Bar")');
174174
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
175175

176176
await executeActiveDocument();
@@ -189,7 +189,7 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
189189
assert.equal(cell.metadata.statusMessage, '', 'Incorrect Status message');
190190
});
191191
test('Verify output & metadata for executed cell with errors', async () => {
192-
await insertPythonCellAndWait('print(abcd)', 0);
192+
await insertPythonCellAndWait('print(abcd)');
193193
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
194194

195195
await executeActiveDocument();
@@ -215,9 +215,9 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
215215
assert.include(cell.metadata.statusMessage!, 'abcd', 'Must contain error message');
216216
});
217217
test('Updating display data', async () => {
218-
await insertPythonCellAndWait('from IPython.display import Markdown\n', 0);
219-
await insertPythonCellAndWait('dh = display(display_id=True)\n', 1);
220-
await insertPythonCellAndWait('dh.update(Markdown("foo"))\n', 2);
218+
await insertPythonCellAndWait('from IPython.display import Markdown\n');
219+
await insertPythonCellAndWait('dh = display(display_id=True)\n');
220+
await insertPythonCellAndWait('dh.update(Markdown("foo"))\n');
221221
const displayCell = vscodeNotebook.activeNotebookEditor?.document.cells![1]!;
222222
const updateCell = vscodeNotebook.activeNotebookEditor?.document.cells![2]!;
223223

@@ -252,8 +252,7 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
252252
time.sleep(0.1)
253253
print(i)
254254
255-
print("End")`,
256-
0
255+
print("End")`
257256
);
258257
const cell = vscodeNotebook.activeNotebookEditor?.document.cells![0]!;
259258

0 commit comments

Comments
 (0)