Skip to content

Commit

Permalink
Reorder code in test_save_notebook_as_with_error()
Browse files Browse the repository at this point in the history
This test often fails in CI on Windows due to a timeout waiting
for prompt; hopefully setting up the mocks after the notebook is
fully loaded will help.
  • Loading branch information
jitseniesen committed Apr 24, 2023
1 parent 6c47ca0 commit 9f240b4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions spyder_notebook/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ def test_save_notebook(notebook, qtbot, tmpdir):
@flaky(max_runs=3)
def test_save_notebook_as_with_error(mocker, notebook, qtbot, tmpdir):
"""Test that errors are handled in save_as()."""
# Wait for prompt
nbwidget = notebook.get_widget().tabwidget.currentWidget().notebookwidget
qtbot.waitUntil(lambda: prompt_present(nbwidget, qtbot),
timeout=NOTEBOOK_UP)

# Set up mocks
name = osp.join(str(tmpdir), 'save.ipynb')
mocker.patch('spyder_notebook.widgets.notebooktabwidget.getsavefilename',
Expand All @@ -282,11 +287,6 @@ def test_save_notebook_as_with_error(mocker, notebook, qtbot, tmpdir):
mock_critical = mocker.patch('spyder_notebook.widgets.notebooktabwidget'
'.QMessageBox.critical')

# Wait for prompt
nbwidget = notebook.get_widget().tabwidget.currentWidget().notebookwidget
qtbot.waitUntil(lambda: prompt_present(nbwidget, qtbot),
timeout=NOTEBOOK_UP)

# Save the notebook
notebook.get_widget().save_as()

Expand Down

0 comments on commit 9f240b4

Please sign in to comment.