Skip to content

Commit

Permalink
Testing: Move preferences_dialog_helper to conftest
Browse files Browse the repository at this point in the history
- That's because that function is not a test but an auxiliary function.
- Also, mark some tests as flaky.
  • Loading branch information
ccordoba12 committed Jan 30, 2023
1 parent af2a37e commit 55aa5ec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
22 changes: 22 additions & 0 deletions spyder/app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,28 @@ def create_namespace_project(tmpdir):
spy_project.set_recent_files(abs_filenames)


def preferences_dialog_helper(qtbot, main_window, section):
"""
Open preferences dialog and select page with `section` (CONF_SECTION).
"""
# Wait until the window is fully up
shell = main_window.ipyconsole.get_current_shellwidget()
qtbot.waitUntil(
lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)

main_window.show_preferences()
preferences = main_window.preferences
container = preferences.get_container()

qtbot.waitUntil(lambda: container.dialog is not None,
timeout=5000)
dlg = container.dialog
index = dlg.get_index_by_name(section)
page = dlg.get_page(index)
dlg.set_current_index(index)
return dlg, index, page


# =============================================================================
# ---- Pytest hooks
# =============================================================================
Expand Down
32 changes: 6 additions & 26 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
from spyder.api.plugins import Plugins
from spyder.app.tests.conftest import (
COMPILE_AND_EVAL_TIMEOUT, COMPLETION_TIMEOUT, EVAL_TIMEOUT,
find_desired_tab_in_window, LOCATION, open_file_in_editor, PY37,
read_asset_file, reset_run_code, SHELL_TIMEOUT, start_new_kernel)
find_desired_tab_in_window, LOCATION, open_file_in_editor,
preferences_dialog_helper, PY37, read_asset_file, reset_run_code,
SHELL_TIMEOUT, start_new_kernel)
from spyder.config.base import (
get_home_dir, get_conf_path, get_module_path, running_in_ci)
from spyder.config.manager import CONF
Expand Down Expand Up @@ -1004,6 +1005,7 @@ def test_run_cython_code(main_window, qtbot):
main_window.editor.close_file()


@flaky(max_runs=5)
def test_project_path(main_window, tmpdir, qtbot):
"""Test project path added to spyder_pythonpath and IPython Console."""
projects = main_window.projects
Expand Down Expand Up @@ -2627,30 +2629,7 @@ def test_break_while_running(main_window, qtbot, tmpdir):
main_window.editor.clear_all_breakpoints()


# --- Preferences
# ----------------------------------------------------------------------------
def preferences_dialog_helper(qtbot, main_window, section):
"""
Open preferences dialog and select page with `section` (CONF_SECTION).
"""
# Wait until the window is fully up
shell = main_window.ipyconsole.get_current_shellwidget()
qtbot.waitUntil(
lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)

main_window.show_preferences()
preferences = main_window.preferences
container = preferences.get_container()

qtbot.waitUntil(lambda: container.dialog is not None,
timeout=5000)
dlg = container.dialog
index = dlg.get_index_by_name(section)
page = dlg.get_page(index)
dlg.set_current_index(index)
return dlg, index, page


@flaky(max_runs=5)
def test_preferences_run_section_exists(main_window, qtbot):
"""
Test for spyder-ide/spyder#13524 regression.
Expand Down Expand Up @@ -5360,6 +5339,7 @@ def test_switch_to_plugin(main_window, qtbot):
assert QApplication.focusWidget() is code_editor


@flaky(max_runs=5)
def test_PYTHONPATH_in_consoles(main_window, qtbot, tmp_path):
"""
Test that PYTHONPATH is passed to IPython consoles under different
Expand Down

0 comments on commit 55aa5ec

Please sign in to comment.