Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into pr_3669
  • Loading branch information
terryjreedy committed May 13, 2023
commit 0aea634486918d545afdbf3c4a493981d13f516b
23 changes: 14 additions & 9 deletions Lib/idlelib/idle_test/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from functools import partial
import sys
from test.support import requires

import unittest
from unittest import mock
import tkinter as tk
Expand Down Expand Up @@ -202,7 +203,8 @@ def test_indent_and_newline_event(self):
text.tag_add('sel', '1.17', '1.end')
nl(None)
# Deletes selected text before adding new line.
eq(get('1.0', 'end'), ' def f1(self, a,\n \n return a + b\n')
eq(get('1.0', 'end'),
' def f1(self, a,\n \n return a + b\n')


class RMenuTest(unittest.TestCase):
Expand Down Expand Up @@ -259,9 +261,9 @@ def test_get_accelerator(self, mock_cocoa):
eq(ga(keydefs, '<<cancel>>'), 'Ctrl+Break') # Cancel to Ctrl-Break.
eq(ga(keydefs, '<<open-module>>'), 'Ctrl+Shift+O') # Shift doesn't change.

# Cocoa test.
# Cocoa test: it skips open-module shortcut.
mock_cocoa.return_value = True
eq(ga(keydefs, '<<open-module>>'), '') # Cocoa skips open-module shortcut.
eq(ga(keydefs, '<<open-module>>'), '')


class MenubarTest(unittest.TestCase):
Expand Down Expand Up @@ -376,7 +378,8 @@ def test_reset_help_menu_entries(self, mock_extrahelp):
mock_callback = w._extra_help_callback

# Create help menu.
help = w.menudict['help'] = tk.Menu(w.menubar, name='help', tearoff=False)
help = w.menudict['help'] = tk.Menu(w.menubar, name='help',
tearoff=False)
cmd = mock_callback.return_value = lambda e: 'break'
help.add_command(label='help1', command=cmd)
w.base_helpmenu_length = help.index('end')
Expand Down Expand Up @@ -413,7 +416,7 @@ def test_get_var_obj(self):
self.assertIsInstance(gvo('<<toggle-debugger>>'), tk.BooleanVar)

@mock.patch.object(editor.webbrowser, 'open')
@unittest.skipIf(sys.platform.startswith('win'), 'this is test for nix system')
@unittest.skipIf(sys.platform.startswith('win'), 'Unix only')
def test__extra_help_callback_not_windows(self, mock_openfile):
w = self.mock_editwin
ehc = partial(w._EditorWindow__extra_help_callback, w)
Expand All @@ -426,20 +429,22 @@ def test__extra_help_callback_not_windows(self, mock_openfile):
mock_openfile.called_with('/foo/bar/baz')

@mock.patch.object(editor.os, 'startfile')
@unittest.skipIf(not sys.platform.startswith('win'), 'this is test for windows system')
@unittest.skipIf(not sys.platform.startswith('win'), 'Windows only')
def test_extra_help_callback_windows(self, mock_start):
# os.startfile doesn't exist on other platforms.
w = self.mock_editwin
w.showerror = mock.Mock()
def ehc(source):
return Editor._extra_help_callback(w, source)
ehc('http://python.org')
mock_start.called_with('http://python.org')
# 'called_with' requires spec tjr
#mock_start.called_with('http://python.org')
# Filename that doesn't open.
mock_start.side_effect = OSError('boom')
# But get '(X)' tk box 'Document Start Fa...' that needs OK click.
#mock_start.side_effect = OSError('boom')
ehc('/foo/bar/baz/')()
self.assertTrue(w.showerror.callargs.kwargs)


class BindingsTest(unittest.TestCase):

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.