Move repeated assert mode

Moved 'assert mode == keyboard_mode' ouside the branches.
This means that if a unknown mode comes its gonna get catched by the
assert and never gona get to the else statement.
For this, the else stament moved to before the assert, caching the mode
error before the assert.
This commit is contained in:
Luis Rodriguez 2019-05-17 09:03:15 -07:00
parent 6679891464
commit 799b8be841

View File

@ -442,24 +442,19 @@ def validate_dualmode_state(notebook, mode, index):
cell_index = notebook.browser.execute_script(JS)
assert cell_index == [index] #only the index cell is selected
if mode == 'command':
#validate mode
assert mode == keyboard_mode #keyboard mode is correct
if mode != 'command' and mode != 'edit':
raise Exception('An unknown mode was send: mode = "%s"'%mode) #An unknown mode is send
#validate mode
assert mode == keyboard_mode #keyboard mode is correct
if mode == 'command':
assert is_focused_on(None) #no focused cells
assert is_only_cell_edit(None) #no cells in edit mode
elif mode == 'edit':
#Are the notebook and keyboard manager in edit mode?
assert mode == keyboard_mode #keyboard mode is correct
assert is_focused_on(index) #The specified cell is focused
assert is_only_cell_edit(index) #The specified cell is the only one in edit mode
else:
raise Exception('An unknown mode was send: mode = "%s"'%mode) #An unknown mode is send