Skip to content

Commit

Permalink
Add outlineexplorer test for display_variables
Browse files Browse the repository at this point in the history
  • Loading branch information
remisalmon committed Nov 2, 2023
1 parent c360651 commit eff89d0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spyder/plugins/outlineexplorer/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,48 @@ def test_go_to_last_item(create_outlineexplorer, qtbot):
assert outlineexplorer.treewidget.currentItem().text(0) == 'method1'


@flaky(max_runs=10)
def test_display_variables(create_outlineexplorer, qtbot):
"""
Test that clicking on the 'Display variables and attributes' button located in the
toolbar of the outline explorer is working as expected by updating the tree widget.
Regression test for spyder-ide/spyder#21456.
"""
outlineexplorer, _ = create_outlineexplorer('text')

editor = outlineexplorer.treewidget.current_editor
state = outlineexplorer.treewidget.display_variables

editor_id = editor.get_id()

initial_tree = outlineexplorer.treewidget.editor_tree_cache[editor_id]

# Click on the 'Display variables and attributes' button of the outline explorer's
# toolbar :
# qtbot.mouseClick(
# TODO,
# Qt.LeftButton)

outlineexplorer.treewidget.toggle_variables(not state)

first_toggle_tree = outlineexplorer.treewidget.editor_tree_cache[editor_id]

assert first_toggle_tree != initial_tree

# Click on the 'Display variables and attributes' button of the outline explorer's
# toolbar :
# qtbot.mouseClick(
# TODO,
# Qt.LeftButton)
outlineexplorer.treewidget.toggle_variables(state)

second_toggle_tree = outlineexplorer.treewidget.editor_tree_cache[editor_id]

assert (second_toggle_tree != first_toggle_tree) and (
second_toggle_tree == initial_tree)


if __name__ == "__main__":
import os
pytest.main(['-x', os.path.basename(__file__), '-v', '-rw'])

0 comments on commit eff89d0

Please sign in to comment.