2
2
// Test buffering for execution requests.
3
3
//
4
4
casper . notebook_test ( function ( ) {
5
- this . evaluate ( function ( ) {
5
+ this . then ( function ( ) {
6
+ // make sure there are at least three cells for the tests below.
7
+ this . append_cell ( ) ;
8
+ this . append_cell ( ) ;
9
+ this . append_cell ( ) ;
10
+ } )
11
+
12
+ this . thenEvaluate ( function ( ) {
13
+ IPython . notebook . kernel . stop_channels ( ) ;
6
14
var cell = IPython . notebook . get_cell ( 0 ) ;
7
15
cell . set_text ( 'a=10; print(a)' ) ;
8
- IPython . notebook . kernel . stop_channels ( ) ;
9
16
IPython . notebook . execute_cells ( [ 0 ] ) ;
10
17
IPython . notebook . kernel . reconnect ( 1 ) ;
11
18
} ) ;
@@ -14,23 +21,36 @@ casper.notebook_test(function () {
14
21
15
22
this . then ( function ( ) {
16
23
var result = this . get_output_cell ( 0 ) ;
17
- this . test . assertEquals ( result . text , '10\n' , 'kernels buffer execution requests if connection is down' ) ;
24
+ this . test . assertEquals ( result . text , '10\n' , 'kernels buffer messages if connection is down' ) ;
18
25
} ) ;
19
-
26
+
20
27
this . thenEvaluate ( function ( ) {
21
28
var cell = IPython . notebook . get_cell ( 0 ) ;
22
- cell . set_text ( 'a=11; print(a)' ) ;
23
- cell . kernel = null ;
24
- IPython . notebook . kernel = null ;
29
+ var cellplus = IPython . notebook . get_cell ( 1 ) ;
30
+ var cellprint = IPython . notebook . get_cell ( 2 ) ;
31
+ cell . set_text ( 'k=1' ) ;
32
+ cellplus . set_text ( 'k+=1' ) ;
33
+ cellprint . set_text ( 'k*=2' )
34
+
35
+ IPython . notebook . kernel . stop_channels ( ) ;
36
+
37
+ // Repeated execution of cell queued up in the kernel executes
38
+ // each execution request in order.
25
39
IPython . notebook . execute_cells ( [ 0 ] ) ;
26
- IPython . notebook . _session_started ( ) ;
40
+ IPython . notebook . execute_cells ( [ 2 ] ) ;
41
+ IPython . notebook . execute_cells ( [ 1 ] ) ;
42
+ IPython . notebook . execute_cells ( [ 1 ] ) ;
43
+ IPython . notebook . execute_cells ( [ 1 ] ) ;
44
+ cellprint . set_text ( 'print(k)' )
45
+ IPython . notebook . execute_cells ( [ 2 ] ) ;
46
+
47
+ IPython . notebook . kernel . reconnect ( 1 ) ;
27
48
} ) ;
28
49
29
- this . wait_for_output ( 0 ) ;
50
+ this . wait_for_output ( 2 ) ;
30
51
31
52
this . then ( function ( ) {
32
- var result = this . get_output_cell ( 0 ) ;
33
- this . test . assertEquals ( result . text , '11 \n' , 'notebooks buffer cell execution requests if kernel is not set ' ) ;
53
+ var result = this . get_output_cell ( 2 ) ;
54
+ this . test . assertEquals ( result . text , '5 \n' , 'kernels send buffered messages in order ' ) ;
34
55
} ) ;
35
-
36
56
} ) ;
0 commit comments