Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should render all markdown cells on an error', async () => {
widget.activeCell.model.value.text = ERROR_INPUT;
const cell = widget.widgets[1] as MarkdownCell;
cell.rendered = false;
const result = await NotebookActions.runAll(widget, ipySession);
// Markdown rendering is asynchronous, but the cell
// provides no way to hook into that. Sleep here
// to make sure it finishes.
await sleep(100);
expect(result).to.equal(false);
expect(cell.rendered).to.equal(true);
await ipySession.kernel.restart();
}).timeout(60000); // Allow for slower CI
});
it('should stop executing code cells on an error', async () => {
widget.activeCell.model.value.text = ERROR_INPUT;
const cell = widget.model.contentFactory.createCodeCell({});
widget.model.cells.push(cell);
const result = await NotebookActions.runAll(widget, ipySession);
expect(result).to.equal(false);
expect(cell.executionCount).to.be.null;
expect(widget.activeCellIndex).to.equal(widget.widgets.length - 1);
await ipySession.kernel.restart();
}).timeout(30000); // Allow for slower CI
runAll: current => {
const { context, notebook } = current;
return NotebookActions.runAll(notebook, context.session)
.then(() => void 0);
},
restartAndRunAll: current => {
return session.restart().then(restarted => {
if (restarted) {
NotebookActions.runAll(notebook, context.session);
}
return restarted;
});
}
execute: () => {
return NotebookActions.runAll(
nbWidget.content,
nbWidget.context.session
);
}
});
return nbWidget.session.restart().then(restarted => {
if (restarted) {
void NotebookActions.runAll(
nbWidget.content,
nbWidget.context.session
);
}
return restarted;
});
}
.then(() => { NotebookActions.runAll(notebook, context.session); });
}
source: [
"import altair as alt\n",
"import pandas as pd\n",
"import json\n",
`with open('${PathExt.basename(
context.path
)}') as json_data:\n`,
" data_src = json.load(json_data)\n",
"data = data_src['data']\n",
"alt.Chart.from_dict(data_src)\n"
]
}
];
(widget as NotebookPanel).model.fromJSON(md);
widget.context.save();
NotebookActions.runAll(widget.notebook, widget.context.session);
});
});
nbWidget.context.session.restart().then(() => {
NotebookActions.runAll(nbWidget.content, nbWidget.context.session);
});
}
.then(restarted => {
if (restarted) {
NotebookActions.runAll(notebook, context.session);
}
return restarted;
});
}