##// END OF EJS Templates
refactor of get_output_cell
Paul Ivanov -
Show More
@@ -15,11 +15,8 casper.notebook_test(function () {
15 this.wait_for_output(0);
15 this.wait_for_output(0);
16
16
17 this.then(function () {
17 this.then(function () {
18 var result = this.evaluate(function () {
18 var result = this.get_output_cell(0);
19 var cell = IPython.notebook.get_cell(0);
19 this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (mouseclick)');
20 return cell.output_area.outputs[0].ename;
21 })
22 this.test.assertEquals(result, 'KeyboardInterrupt', 'keyboard interrupt (mouseclick)');
23 });
20 });
24
21
25 // run cell 0 again, now interrupting using keyboard shortcut
22 // run cell 0 again, now interrupting using keyboard shortcut
@@ -36,10 +33,7 casper.notebook_test(function () {
36 this.wait_for_output(0);
33 this.wait_for_output(0);
37
34
38 this.then(function () {
35 this.then(function () {
39 var result = this.evaluate(function () {
36 var result = this.get_output_cell(0);
40 var cell = IPython.notebook.get_cell(0);
37 this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (shortcut)');
41 return cell.output_area.outputs[0].ename;
42 });
43 this.test.assertEquals(result, 'KeyboardInterrupt', 'keyboard interrupt (shortcut)');
44 });
38 });
45 });
39 });
@@ -10,13 +10,10 casper.notebook_test(function () {
10
10
11 this.wait_for_output(0);
11 this.wait_for_output(0);
12
12
13 // refactor this into just a get_output(0)
13 this.then(function () {
14 this.then(function () {
14 var result = this.evaluate(function () {
15 var result = this.get_output_cell(0);
15 var cell = IPython.notebook.get_cell(0);
16 this.test.assertEquals(result.text, '10\n', 'cell execute (using js)')
16 var output = cell.output_area.outputs[0].text;
17 return output;
18 })
19 this.test.assertEquals(result, '10\n', 'cell execute (using js)')
20 });
17 });
21
18
22
19
@@ -31,12 +28,8 casper.notebook_test(function () {
31 this.wait_for_output(0);
28 this.wait_for_output(0);
32
29
33 this.then(function () {
30 this.then(function () {
34 var result = this.evaluate(function () {
31 var result = this.get_output_cell(0);
35 var cell = IPython.notebook.get_cell(0);
32 this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)')
36 var output = cell.output_area.outputs[0].text;
37 return output;
38 })
39 this.test.assertEquals(result, '11\n', 'cell execute (using ctrl-enter)')
40 });
33 });
41
34
42 // do it again with the keyboard shortcut
35 // do it again with the keyboard shortcut
@@ -50,11 +43,7 casper.notebook_test(function () {
50 this.wait_for_output(0);
43 this.wait_for_output(0);
51
44
52 this.then(function () {
45 this.then(function () {
53 var result = this.evaluate(function () {
46 var result = this.get_output_cell(0);
54 var cell = IPython.notebook.get_cell(0);
47 this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)')
55 var output = cell.output_area.outputs[0].text;
56 return output;
57 })
58 this.test.assertEquals(result, '12\n', 'cell execute (using shift-enter)')
59 });
48 });
60 });
49 });
@@ -68,6 +68,16 casper.wait_for_output = function (cell_num) {
68 });
68 });
69 };
69 };
70
70
71 // return the output of a given cell
72 casper.get_output_cell = function (cell_num) {
73 var result = casper.evaluate(function (c) {
74 var cell = IPython.notebook.get_cell(c);
75 return cell.output_area.outputs[0];
76 },
77 {c : cell_num});
78 return result;
79 };
80
71 // Wrap a notebook test to reduce boilerplate.
81 // Wrap a notebook test to reduce boilerplate.
72 casper.notebook_test = function(test) {
82 casper.notebook_test = function(test) {
73 this.open_new_notebook();
83 this.open_new_notebook();
General Comments 0
You need to be logged in to leave comments. Login now