Skip to content

Commit

Permalink
Testing: Fix failing main window tests related to debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Jun 12, 2024
1 parent 6aedd1b commit 73a79ff
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5858,25 +5858,25 @@ def test_debugger_plugin(main_window, qtbot):

# Test post mortem
with qtbot.waitSignal(shell.executed):
debugger.enter_debug()
debugger.enter_debugger_after_exception()

assert len(frames_browser.stack_dict) == 1
assert list(frames_browser.stack_dict.keys())[0] == "pdb"
assert list(frames_browser.stack_dict.keys())[0] == "Frames"
assert not enter_debug_action.isEnabled()

# Test that executing a statement doesn't change the frames browser
with qtbot.waitSignal(shell.executed):
shell.execute('a = 1')

assert len(frames_browser.stack_dict) == 1
assert list(frames_browser.stack_dict.keys())[0] == "pdb"
assert list(frames_browser.stack_dict.keys())[0] == "Frames"
assert not enter_debug_action.isEnabled()

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

assert len(frames_browser.stack_dict) == 1
assert list(frames_browser.stack_dict.keys())[0] == "pdb"
assert list(frames_browser.stack_dict.keys())[0] == "Frames"
assert not enter_debug_action.isEnabled()

# Test that quitting resets the explorer
Expand All @@ -5891,7 +5891,7 @@ def test_debugger_plugin(main_window, qtbot):
shell.execute('%debug print()')

assert len(frames_browser.stack_dict) == 1
assert list(frames_browser.stack_dict.keys())[0] == "pdb"
assert list(frames_browser.stack_dict.keys())[0] == "Frames"
assert not enter_debug_action.isEnabled()

# Restart Kernel
Expand All @@ -5911,7 +5911,7 @@ def test_debugger_plugin(main_window, qtbot):
shell.execute('%debug print()')

assert len(frames_browser.stack_dict) == 1
assert list(frames_browser.stack_dict.keys())[0] == "pdb"
assert list(frames_browser.stack_dict.keys())[0] == "Frames"
assert not enter_debug_action.isEnabled()

# Crash Kernel
Expand All @@ -5923,7 +5923,7 @@ def test_debugger_plugin(main_window, qtbot):


@flaky(max_runs=3)
def test_enter_debugger(main_window, qtbot):
def test_interrupt_and_debug(main_window, qtbot):
"""
Test that we can enter the debugger while code is running in the kernel.
"""
Expand All @@ -5934,8 +5934,8 @@ def test_enter_debugger(main_window, qtbot):
timeout=SHELL_TIMEOUT)

debugger = main_window.debugger.get_widget()
enter_debug_action = debugger.get_action(
DebuggerWidgetActions.EnterDebug)
interrupt_debug_action = debugger.get_action(
DebuggerWidgetActions.InterrupAndDebug)
inspect_action = debugger.get_action(
DebuggerWidgetActions.Inspect)

Expand All @@ -5944,18 +5944,18 @@ def test_enter_debugger(main_window, qtbot):
shell.execute('import time')
with qtbot.waitSignal(shell.executed):
shell.execute('%debug for i in range(100): time.sleep(.1)')
assert not enter_debug_action.isEnabled()
assert not interrupt_debug_action.isEnabled()
assert not inspect_action.isEnabled()
shell.execute('c')
qtbot.wait(200)
assert enter_debug_action.isEnabled()
assert interrupt_debug_action.isEnabled()
assert inspect_action.isEnabled()

# enter the debugger
with qtbot.waitSignal(shell.executed):
debugger.enter_debug()
debugger.interrupt_and_debug()
# make sure we are stopped somewhere in the middle
assert not enter_debug_action.isEnabled()
assert not interrupt_debug_action.isEnabled()
assert not inspect_action.isEnabled()
assert shell.is_debugging()
assert 0 < shell.get_value("i") < 99
Expand All @@ -5970,32 +5970,32 @@ def test_enter_debugger(main_window, qtbot):
return

# Check we can enter the debugger
assert not enter_debug_action.isEnabled()
assert not interrupt_debug_action.isEnabled()
assert not inspect_action.isEnabled()
shell.execute('for i in range(100): time.sleep(.1)')
qtbot.wait(200)

assert enter_debug_action.isEnabled()
assert interrupt_debug_action.isEnabled()
assert inspect_action.isEnabled()

# enter the debugger
with qtbot.waitSignal(shell.executed):
debugger.enter_debug()
debugger.interrupt_and_debug()
assert shell.is_debugging()

# make sure we are stopped somewhere in the middle
assert not enter_debug_action.isEnabled()
assert not interrupt_debug_action.isEnabled()
assert not inspect_action.isEnabled()
assert 0 < shell.get_value("i") < 99

shell.execute('c')
qtbot.wait(200)
# enter the debugger
with qtbot.waitSignal(shell.executed):
debugger.enter_debug()
debugger.interrupt_and_debug()

# make sure we are stopped somewhere in the middle
assert not enter_debug_action.isEnabled()
assert not interrupt_debug_action.isEnabled()
assert not inspect_action.isEnabled()
assert 0 < shell.get_value("i") < 99

Expand Down Expand Up @@ -6025,21 +6025,21 @@ def test_recursive_debug(main_window, qtbot):
with qtbot.waitSignal(shell.executed):
shell.execute('s')
# a in framesbrowser
assert frames_browser.stack_dict['pdb'][2]["name"] == 'a'
assert frames_browser.stack_dict['Frames'][2]["name"] == 'a'

# Recursive debug
with qtbot.waitSignal(shell.executed):
shell.execute('debug b()')
with qtbot.waitSignal(shell.executed):
shell.execute('s')
# b in framesbrowser
assert frames_browser.stack_dict['pdb'][2]["name"] == 'b'
assert frames_browser.stack_dict['Frames'][2]["name"] == 'b'

# Quit recursive debugger
with qtbot.waitSignal(shell.executed):
shell.execute('q')
# a in framesbrowser
assert frames_browser.stack_dict['pdb'][2]["name"] == 'a'
assert frames_browser.stack_dict['Frames'][2]["name"] == 'a'

# quit debugger
with qtbot.waitSignal(shell.executed):
Expand Down

0 comments on commit 73a79ff

Please sign in to comment.