refactor of get_output_cell

Paul Ivanov 12 years ago
parent 047f3d76cc
commit 89f2ed95f9

@ -15,11 +15,8 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
var result = this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
return cell.output_area.outputs[0].ename;
})
this.test.assertEquals(result, 'KeyboardInterrupt', 'keyboard interrupt (mouseclick)');
var result = this.get_output_cell(0);
this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (mouseclick)');
});
// run cell 0 again, now interrupting using keyboard shortcut
@ -36,10 +33,7 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
var result = this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
return cell.output_area.outputs[0].ename;
});
this.test.assertEquals(result, 'KeyboardInterrupt', 'keyboard interrupt (shortcut)');
var result = this.get_output_cell(0);
this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (shortcut)');
});
});

@ -10,13 +10,10 @@ casper.notebook_test(function () {
this.wait_for_output(0);
// refactor this into just a get_output(0)
this.then(function () {
var result = this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
var output = cell.output_area.outputs[0].text;
return output;
})
this.test.assertEquals(result, '10\n', 'cell execute (using js)')
var result = this.get_output_cell(0);
this.test.assertEquals(result.text, '10\n', 'cell execute (using js)')
});
@ -31,12 +28,8 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
var result = this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
var output = cell.output_area.outputs[0].text;
return output;
})
this.test.assertEquals(result, '11\n', 'cell execute (using ctrl-enter)')
var result = this.get_output_cell(0);
this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)')
});
// do it again with the keyboard shortcut
@ -50,11 +43,7 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
var result = this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
var output = cell.output_area.outputs[0].text;
return output;
})
this.test.assertEquals(result, '12\n', 'cell execute (using shift-enter)')
var result = this.get_output_cell(0);
this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)')
});
});

@ -68,6 +68,16 @@ casper.wait_for_output = function (cell_num) {
});
};
// return the output of a given cell
casper.get_output_cell = function (cell_num) {
var result = casper.evaluate(function (c) {
var cell = IPython.notebook.get_cell(c);
return cell.output_area.outputs[0];
},
{c : cell_num});
return result;
};
// Wrap a notebook test to reduce boilerplate.
casper.notebook_test = function(test) {
this.open_new_notebook();

Loading…
Cancel
Save