From 8776f4f30d7d8fd9486d321a1b878199934f0790 Mon Sep 17 00:00:00 2001 From: Julian Gilbey Date: Mon, 24 Jul 2023 22:36:26 +0100 Subject: [PATCH] Do not overwrite test script to allow tests to be rerun --- spyder/app/tests/test_mainwindow.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spyder/app/tests/test_mainwindow.py b/spyder/app/tests/test_mainwindow.py index f9f8c5cba78..d079e55ad85 100644 --- a/spyder/app/tests/test_mainwindow.py +++ b/spyder/app/tests/test_mainwindow.py @@ -5417,8 +5417,8 @@ def test_PYTHONPATH_in_consoles(main_window, qtbot, tmp_path, assert str(new_dir) in shell.get_value("sys_path") -@flaky(max_runs=3) -def test_clickable_ipython_tracebacks(main_window, qtbot, tmpdir): +@flaky(max_runs=10) +def test_clickable_ipython_tracebacks(main_window, qtbot, tmp_path): """ Test that file names in IPython console tracebacks are clickable. @@ -5429,8 +5429,11 @@ def test_clickable_ipython_tracebacks(main_window, qtbot, tmpdir): qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT) - # Open test file - test_file = osp.join(LOCATION, 'script.py') + # Copy test file to a temporary location to avoid modifying it. + # See spyder-ide/spyder#21186 for the details + test_file_orig = osp.join(LOCATION, 'script.py') + test_file = str(tmp_path / 'script.py') + shutil.copyfile(test_file_orig, test_file) main_window.editor.load(test_file) code_editor = main_window.editor.get_focus_widget() @@ -5473,11 +5476,6 @@ def test_clickable_ipython_tracebacks(main_window, qtbot, tmpdir): cursor = code_editor.textCursor() assert cursor.blockNumber() == code_editor.blockCount() - 1 - # Remove error and save file - code_editor.delete_line() - code_editor.sig_save_requested.emit() - qtbot.wait(500) - if __name__ == "__main__": pytest.main()