##// END OF EJS Templates
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook....
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook. Here's a brief overview of the changes: - Display of messages from other clients can be toggled on and off from within a notebook, either using the ``<M-m>e`` keyboard shortcut in the web UI, or through the option in the "Kernel" menu. - notebook.js controls whether messages are displayed through a callback that is invoked from kernel.js when no callbacks are available for a message. - The UI displays ``execute_input`` messages originating from an other clients in new cells at the end of the notebook. Output messages (``execute_result`` et al.) will only be displayed if a cell exists with a matching message ID. Pending design questions: - Should each ``execute_input`` message cause a new cell to be created? - Should new cells be placed at the end of the notebook, or elsewhere? If the latter, what criteria should be followed?

File last commit:

r18584:3954d295
r19164:17ac8ca3
Show More
output.js
98 lines | 2.8 KiB | application/javascript | JavascriptLexer
MinRK
test coalesced output in js
r17307 //
// Various output tests
//
casper.notebook_test(function () {
this.test_coalesced_output = function (msg, code, expected) {
this.then(function () {
this.echo("Test coalesced output: " + msg);
});
this.thenEvaluate(function (code) {
IPython.notebook.insert_cell_at_index(0, "code");
var cell = IPython.notebook.get_cell(0);
cell.set_text(code);
cell.execute();
}, {code: code});
this.wait_for_output(0);
this.then(function () {
var results = this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
return cell.output_area.outputs;
});
this.test.assertEquals(results.length, expected.length, "correct number of outputs");
for (var i = 0; i < results.length; i++) {
var r = results[i];
var ex = expected[i];
this.test.assertEquals(r.output_type, ex.output_type, "output " + i);
if (r.output_type === 'stream') {
MinRK
update html/js to nbformat 4
r18584 this.test.assertEquals(r.name, ex.name, "stream " + i);
MinRK
test coalesced output in js
r17307 this.test.assertEquals(r.text, ex.text, "content " + i);
}
}
});
};
this.thenEvaluate(function () {
IPython.notebook.insert_cell_at_index(0, "code");
var cell = IPython.notebook.get_cell(0);
cell.set_text([
"from __future__ import print_function",
"import sys",
"from IPython.display import display"
].join("\n")
);
cell.execute();
});
this.test_coalesced_output("stdout", [
"print(1)",
"sys.stdout.flush()",
"print(2)",
"sys.stdout.flush()",
"print(3)"
].join("\n"), [{
output_type: "stream",
MinRK
update html/js to nbformat 4
r18584 name: "stdout",
MinRK
test coalesced output in js
r17307 text: "1\n2\n3\n"
}]
);
this.test_coalesced_output("stdout+sdterr", [
"print(1)",
"sys.stdout.flush()",
"print(2)",
"print(3, file=sys.stderr)"
].join("\n"), [{
output_type: "stream",
MinRK
update html/js to nbformat 4
r18584 name: "stdout",
MinRK
test coalesced output in js
r17307 text: "1\n2\n"
},{
output_type: "stream",
MinRK
update html/js to nbformat 4
r18584 name: "stderr",
MinRK
test coalesced output in js
r17307 text: "3\n"
}]
);
this.test_coalesced_output("display splits streams", [
"print(1)",
"sys.stdout.flush()",
"display(2)",
"print(3)"
].join("\n"), [{
output_type: "stream",
MinRK
update html/js to nbformat 4
r18584 name: "stdout",
MinRK
test coalesced output in js
r17307 text: "1\n"
},{
output_type: "display_data",
},{
output_type: "stream",
MinRK
update html/js to nbformat 4
r18584 name: "stdout",
MinRK
test coalesced output in js
r17307 text: "3\n"
}]
);
});