Modified to avoid race condition

This commit is contained in:
TPartida 2019-05-15 11:27:59 -07:00 committed by Thomas Kluyver
parent 6811727a25
commit c23de34161

View File

@ -1,5 +1,5 @@
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from .utils import shift, cmdtrl from .utils import shift, cmdtrl, wait_for_selector
import time import time
@ -14,29 +14,34 @@ def test_execute_code(notebook):
notebook.edit_cell(index=0, content='a=10; print(a)') notebook.edit_cell(index=0, content='a=10; print(a)')
notebook.execute_cell(0) notebook.execute_cell(0)
wait_for_selector(notebook.browser, 'div.output_area')
assert get_output_text() == '10', 'cell execute (using js)' assert get_output_text() == '10', 'cell execute (using js)'
notebook.edit_cell(index=0, content='a=11; print(a)') notebook.edit_cell(index=0, content='a=11; print(a)')
clear_outputs() clear_outputs()
shift(notebook.browser, Keys.ENTER) shift(notebook.browser, Keys.ENTER)
notebook.delete_cell(index=1) notebook.delete_cell(index=1)
wait_for_selector(notebook.browser, 'div.output_area')
assert get_output_text() == '11', 'cell execute (using shift-enter)' assert get_output_text() == '11', 'cell execute (using shift-enter)'
notebook.edit_cell(index=0, content='a=12; print(a)') notebook.edit_cell(index=0, content='a=12; print(a)')
clear_outputs() clear_outputs()
cmdtrl(notebook.browser, Keys.ENTER) cmdtrl(notebook.browser, Keys.ENTER)
wait_for_selector(notebook.browser, 'div.output_area')
assert get_output_text() == '12', 'cell execute (using ctrl-enter)' assert get_output_text() == '12', 'cell execute (using ctrl-enter)'
notebook.edit_cell(index=0, content='a=13; print(a)') notebook.edit_cell(index=0, content='a=13; print(a)')
clear_outputs() clear_outputs()
notebook.browser.find_element_by_css_selector( notebook.browser.find_element_by_css_selector(
"button[data-jupyter-action='jupyter-notebook:run-cell-and-select-next']").click() "button[data-jupyter-action='jupyter-notebook:run-cell-and-select-next']").click()
wait_for_selector(notebook.browser, 'div.output_area')
assert get_output_text() == '13', 'cell execute (cell execute (using "play" toolbar button))' assert get_output_text() == '13', 'cell execute (cell execute (using "play" toolbar button))'
notebook.edit_cell(index=0, content='raise IOError') notebook.edit_cell(index=0, content='raise IOError')
notebook.edit_cell(index=1, content='a=14; print(a)') notebook.edit_cell(index=1, content='a=14; print(a)')
clear_outputs() clear_outputs()
notebook.execute_cell(1) notebook.execute_cell(1)
wait_for_selector(notebook.browser, 'div.output_area')
assert get_output_text(1) == '14', "cell execute, don't stop on error" assert get_output_text(1) == '14', "cell execute, don't stop on error"
clear_outputs() clear_outputs()