Skip to content

Commit

Permalink
Fix some tests failing on Python 3.12 (spyder-ide#21688)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Gilbey committed Jan 10, 2024
1 parent 87772f3 commit 2b737f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
8 changes: 2 additions & 6 deletions spyder/plugins/editor/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,8 @@ def test_renamed_tree(editor_plugin, mocker):

editor.renamed_tree('/test/directory', '/test/dir')
assert editor.renamed.call_count == 3
assert editor.renamed.called_with(source='/test/directory/file1.py',
dest='test/dir/file1.py')
assert editor.renamed.called_with(source='/test/directory/file2.txt',
dest='test/dir/file2.txt')
assert editor.renamed.called_with(source='/test/directory/file4.rst',
dest='test/dir/file4.rst')
editor.renamed.assert_called_with(source='/test/directory/file4.rst',
dest='/test/dir/file4.rst')


def test_no_template(editor_plugin):
Expand Down
14 changes: 12 additions & 2 deletions spyder/plugins/editor/widgets/tests/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ def test_update_warnings_after_closequotes(qtbot, completions_codeeditor_linting
editor, _ = completions_codeeditor_linting
editor.textCursor().insertText("print('test)\n")

if sys.version_info >= (3, 10):
if sys.version_info >= (3, 12):
expected = [
['unterminated string literal (detected at line 1)', 1],
['E901 TokenError: unterminated string literal (detected at line 1)', 1]
]
elif sys.version_info >= (3, 10):
expected = [['unterminated string literal (detected at line 1)', 1]]
else:
expected = [['EOL while scanning string literal', 1]]
Expand Down Expand Up @@ -302,7 +307,12 @@ def test_update_warnings_after_closebrackets(qtbot, completions_codeeditor_linti
editor, _ = completions_codeeditor_linting
editor.textCursor().insertText("print('test'\n")

if sys.version_info >= (3, 10):
if sys.version_info >= (3, 12):
expected = [
["'(' was never closed", 1],
['E901 TokenError: unexpected EOF in multi-line statement', 1]
]
elif sys.version_info >= (3, 10):
expected = [
["'(' was never closed", 1],
['E901 TokenError: EOF in multi-line statement', 2]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def error_attribute(self):
([1, 3, 4, 'kjkj', None], [45, 48]),
({1, 2, 1, 3, None, 'A', 'B', 'C', True, False}, [54, 57]),
(1.2233, [57, 59]),
(np.random.rand(10, 10), [166, 162]),
(np.random.rand(10, 10), [162, 167]),
(datetime.date(1945, 5, 8), [43, 48])
])
def test_objectexplorer_collection_types(objectexplorer, params):
Expand Down
7 changes: 3 additions & 4 deletions spyder/widgets/tests/test_reporterror.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,21 @@ def test_report_issue_url(monkeypatch):
target_url_base = __project_url__ + '/issues/new'

MockQDesktopServices = MagicMock()
mockQDesktopServices_instance = MockQDesktopServices()
attr_to_patch = ('spyder.widgets.reporterror.QDesktopServices')
monkeypatch.setattr(attr_to_patch, MockQDesktopServices)

# Test when body != None, i.e. when auto-submitting error to Github
target_url = QUrl(target_url_base + '?body=' + body)
SpyderErrorDialog.open_web_report(body=body, title=None)
assert MockQDesktopServices.openUrl.call_count == 1
mockQDesktopServices_instance.openUrl.called_with(target_url)
MockQDesktopServices.openUrl.assert_called_with(target_url)

# Test when body != None and title != None
target_url = QUrl(target_url_base + '?body=' + body
+ "&title=" + title)
SpyderErrorDialog.open_web_report(body=body, title=None)
SpyderErrorDialog.open_web_report(body=body, title=title)
assert MockQDesktopServices.openUrl.call_count == 2
mockQDesktopServices_instance.openUrl.called_with(target_url)
MockQDesktopServices.openUrl.assert_called_with(target_url)


def test_render_issue():
Expand Down

0 comments on commit 2b737f5

Please sign in to comment.