interrupt.js
44 lines
| 1.2 KiB
| application/javascript
|
JavascriptLexer
Paul Ivanov
|
r13289 | // | ||
// Test kernel interrupt | ||||
// | ||||
casper.notebook_test(function () { | ||||
this.evaluate(function () { | ||||
var cell = IPython.notebook.get_cell(0); | ||||
Paul Ivanov
|
r13463 | cell.set_text( | ||
'import time'+ | ||||
'\nfor x in range(3):'+ | ||||
'\n time.sleep(1)' | ||||
); | ||||
Paul Ivanov
|
r13289 | cell.execute(); | ||
}); | ||||
Matthias BUSSONNIER
|
r15042 | this.wait_for_busy(); | ||
Paul Ivanov
|
r13297 | |||
// interrupt using menu item (Kernel -> Interrupt) | ||||
Paul Ivanov
|
r13289 | this.thenClick('li#int_kernel'); | ||
Paul Ivanov
|
r13295 | this.wait_for_output(0); | ||
Paul Ivanov
|
r13289 | |||
this.then(function () { | ||||
Paul Ivanov
|
r13299 | var result = this.get_output_cell(0); | ||
this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (mouseclick)'); | ||||
Paul Ivanov
|
r13297 | }); | ||
// run cell 0 again, now interrupting using keyboard shortcut | ||||
this.thenEvaluate(function () { | ||||
cell.clear_output(); | ||||
cell.execute(); | ||||
}); | ||||
// interrupt using Ctrl-M I keyboard shortcut | ||||
this.thenEvaluate( function() { | ||||
Brian E. Granger
|
r15619 | IPython.keyboard.trigger_keydown('i'); | ||
Paul Ivanov
|
r13297 | }); | ||
this.wait_for_output(0); | ||||
this.then(function () { | ||||
Paul Ivanov
|
r13299 | var result = this.get_output_cell(0); | ||
this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (shortcut)'); | ||||
Paul Ivanov
|
r13289 | }); | ||
}); | ||||