@@ -4,29 +4,31 @@ def test_merge_cells(notebook):
44 # Add cells to notebook
55 a = "foo = 5"
66 b = "bar = 10"
7- c = "print(foo)"
8- d = "print(bar)"
7+ c = "baz = 15"
8+ d = "print(foo)"
9+ e = "print(bar)"
10+ f = "print(baz)"
911 notebook .edit_cell (index = 0 , content = a )
10- notebook .append (b , c , d )
12+ notebook .append (b , c , d , e , f )
1113
12- # Before merging, there are 4 separate cells
13- assert notebook .get_cells_contents () == [a , b , c , d ]
14+ # Before merging, there are 6 separate cells
15+ assert notebook .get_cells_contents () == [a , b , c , d , e , f ]
1416
1517 # Focus on the second cell and merge it with the cell above
1618 notebook .focus_cell (1 )
1719 notebook .browser .execute_script ("Jupyter.notebook.merge_cell_above();" )
1820 merged_a_b = "%s\n \n %s" % (a , b )
19- assert notebook .get_cells_contents () == [merged_a_b , c , d ]
21+ assert notebook .get_cells_contents () == [merged_a_b , c , d , e , f ]
2022
2123 # Focus on the second cell and merge it with the cell below
2224 notebook .focus_cell (1 )
2325 notebook .browser .execute_script ("Jupyter.notebook.merge_cell_below();" )
2426 merged_c_d = "%s\n \n %s" % (c , d )
25- assert notebook .get_cells_contents () == [merged_a_b , merged_c_d ]
27+ assert notebook .get_cells_contents () == [merged_a_b , merged_c_d , e , f ]
2628
27- # Merge everything down to a single cell
28- notebook .focus_cell ( 0 )
29- notebook .browser .execute_script ("Jupyter.notebook.merge_cell_below ();" )
30- merged_all = "%s\n \n %s" % (merged_a_b , merged_c_d )
29+ # Merge everything down to a single cell with selected cells
30+ notebook .select_cell_range ( 0 , 3 )
31+ notebook .browser .execute_script ("Jupyter.notebook.merge_selected_cells ();" )
32+ merged_all = "%s\n \n %s\n \n %s \n \n %s " % (merged_a_b , merged_c_d , e , f )
3133 assert notebook .get_cells_contents () == [merged_all ]
3234
0 commit comments