Skip to content

Commit

Permalink
Merge from 5.x: PR #17191
Browse files Browse the repository at this point in the history
Fixes #16417
  • Loading branch information
ccordoba12 committed Jan 25, 2022
2 parents 36661ba + 242a2fa commit 86060d7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4409,6 +4409,7 @@ def crash_func():
@flaky(max_runs=3)
@pytest.mark.skipif(os.name == 'nt', reason="Tour messes up focus on Windows")
@pytest.mark.parametrize("focus_to_editor", [True, False])
@pytest.mark.skipif(os.name == 'nt', reason="Fails on Windows")
def test_focus_to_editor(main_window, qtbot, tmpdir, focus_to_editor):
"""Test that the focus_to_editor option works as expected."""
# Write code with cells to a file
Expand Down Expand Up @@ -4593,5 +4594,41 @@ def test_history_from_ipyconsole(main_window, qtbot):
assert text.splitlines()[-1] == code


@pytest.mark.slow
def test_debug_unsaved_function(main_window, qtbot):
"""
Test that a breakpoint in an unsaved file is reached.
"""
# Main variables
shell = main_window.ipyconsole.get_current_shellwidget()
control = shell._control
run_action = main_window.run_toolbar_actions[0]
run_button = main_window.run_toolbar.widgetForAction(run_action)

# Clear all breakpoints
main_window.editor.clear_all_breakpoints()

# create new file
main_window.editor.new()
code_editor = main_window.editor.get_focus_widget()
code_editor.set_text('def foo():\n print(1)')

# Set breakpoint
code_editor.debugger.toogle_breakpoint(line_number=2)

# run file
with qtbot.waitSignal(shell.executed):
qtbot.mouseClick(run_button, Qt.LeftButton)

# debug foo
with qtbot.waitSignal(shell.executed):
shell.execute('%debug foo()')

with qtbot.waitSignal(shell.executed):
shell.execute('continue')

assert "1---> 2 print(1)" in control.toPlainText()


if __name__ == "__main__":
pytest.main()

0 comments on commit 86060d7

Please sign in to comment.