From 9f240b49bcfde5c71ba7e2ab763ab5d675e5efd7 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Mon, 24 Apr 2023 12:17:02 +0100 Subject: [PATCH] Reorder code in test_save_notebook_as_with_error() 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. --- spyder_notebook/tests/test_plugin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spyder_notebook/tests/test_plugin.py b/spyder_notebook/tests/test_plugin.py index d031293d..413c6c23 100644 --- a/spyder_notebook/tests/test_plugin.py +++ b/spyder_notebook/tests/test_plugin.py @@ -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', @@ -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()