Modified to use list comprehension, added '()' for to_command_mode, added assert to check presence of cell and remove 'return True' from remove_cells

This commit is contained in:
arovitn 2018-05-21 18:33:42 -07:00
parent 70ce8fac33
commit 0afa1e5855
2 changed files with 4 additions and 4 deletions

View File

@ -4,10 +4,10 @@
def remove_cells(notebook):
for i in notebook.cells:
notebook.delete_cell(notebook.index(i))
return True
def test_empty_arrows_keys(notebook):
# delete all the cells
notebook.trigger_keydown('up')
notebook.trigger_keydown('down')
assert remove_cells(notebook);
remove_cells(notebook)
assert len(notebook.cells) == 1 # notebook should create one automatically on empty notebook

View File

@ -186,7 +186,7 @@ class Notebook:
def delete_cell(self, index):
self.focus_cell(index)
self.to_command_mode
self.to_command_mode()
self.current_cell.send_keys('dd')
def add_markdown_cell(self, index=-1, content="", render=True):
@ -276,7 +276,7 @@ def trigger_keystrokes(browser, *keys):
for each_key_combination in keys:
keys = each_key_combination.split('-')
if len(keys) > 1: # key has modifiers eg. control, alt, shift
modifiers_keys = list(map(lambda x:getattr(Keys, x.upper()), keys[:-1]))
modifiers_keys = [getattr(Keys, x.upper()) for x in keys[:-1]]
ac = ActionChains(browser)
for i in modifiers_keys: ac = ac.key_down(i)
ac.send_keys(keys[-1])