Skip to content

Commit

Permalink
Testing: Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Jan 3, 2024
1 parent 5ece898 commit d9e7c03
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ def test_update_decorations_when_scrolling(qtbot):

# Only one call to _update should be done, after releasing the key.
qtbot.wait(editor.UPDATE_DECORATIONS_TIMEOUT + 100)
assert _update.call_count == 4
assert _update.call_count == 5

# Simulate continuously pressing the up arrow key.
for __ in range(200):
qtbot.keyPress(editor, Qt.Key_Up)

# Only one call to _update should be done, after releasing the key.
qtbot.wait(editor.UPDATE_DECORATIONS_TIMEOUT + 100)
assert _update.call_count == 5
assert _update.call_count == 6


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# Standard library imports
import os
import sys

# Third party imports
from flaky import flaky
Expand Down Expand Up @@ -140,7 +141,7 @@ def test_unfold_goto(completions_codeeditor, qtbot):

@flaky(max_runs=5)
@pytest.mark.order(2)
@pytest.mark.skipif(os.name == 'nt', reason="Hangs on Windows")
@pytest.mark.skipif(sys.platform.startswith("linux"), reason="Fails on Linux")
def test_delete_folded_line(completions_codeeditor, qtbot):
editor, __ = completions_codeeditor
editor.toggle_code_folding(True)
Expand Down Expand Up @@ -209,7 +210,7 @@ def fold_and_delete_region(key):

@flaky(max_runs=5)
@pytest.mark.order(2)
@pytest.mark.skipif(os.name == 'nt', reason="Hangs on Windows")
@pytest.mark.skipif(sys.platform.startswith("linux"), reason="Fails on Linux")
def test_delete_selections_with_folded_lines(completions_codeeditor, qtbot):
editor, __ = completions_codeeditor
editor.toggle_code_folding(True)
Expand Down Expand Up @@ -292,7 +293,6 @@ def restore_initial_state():

@flaky(max_runs=5)
@pytest.mark.order(2)
@pytest.mark.skipif(os.name == 'nt', reason="Hangs on Windows")
def test_preserve_folded_regions_after_paste(completions_codeeditor, qtbot):
editor, __ = completions_codeeditor
editor.toggle_code_folding(True)
Expand Down
17 changes: 12 additions & 5 deletions spyder/plugins/editor/widgets/editorstack/tests/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def test_save_as_lsp_calls(completions_editor, mocker, qtbot, tmpdir):
"""
Test that EditorStack.save_as() sends the expected LSP requests.
Regression test for spyder-ide/spyder#13085 and spyder-ide/spyder#20047
Regression test for spyder-ide/spyder#13085 and spyder-ide/spyder#20047.
"""
file_path, editorstack, code_editor, completion_plugin = completions_editor

Expand Down Expand Up @@ -572,8 +572,9 @@ def foo(x):
qtbot.waitUntil(symbols_and_folding_processed, timeout=5000)

# Check response by LSP
assert code_editor.handle_folding_range.call_args == \
mocker.call({'params': [(1, 3)]})
assert code_editor.handle_folding_range.call_args == mocker.call(
{"params": [{"startLine": 1, "endLine": 3}]}
)

symbols = [
{
Expand Down Expand Up @@ -664,8 +665,14 @@ def bar():
# responded to the requests).

# Check that LSP responded with updated folding and symbols information
assert code_editor.handle_folding_range.call_args == \
mocker.call({'params': [(1, 5), (7, 9)]})
assert code_editor.handle_folding_range.call_args == mocker.call(
{
"params": [
{"startLine": 1, "endLine": 5},
{"startLine": 7, "endLine": 9},
]
}
)

# There must be 7 symbols (2 functions and 5 variables)
assert len(code_editor.process_symbols.call_args.args[0]['params']) == 7
Expand Down

0 comments on commit d9e7c03

Please sign in to comment.