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
Make test pass; delete redundant asserts.
  • Loading branch information
terryjreedy committed Sep 21, 2020
commit c32379be1f998e608162a176171989e4f5081c5c
24 changes: 9 additions & 15 deletions Lib/idlelib/idle_test/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def test_fill_menus(self):
def test_reset_help_menu_entries(self, mock_extrahelp):
w = self.mock_editwin
mock_extrahelp.return_value = [('Python', 'https://python.org', '1')]
mock_callback = w._EditorWindow__extra_help_callback
mock_callback = w._extra_help_callback

# Create help menu.
help = w.menudict['help'] = tk.Menu(w.menubar, name='help', tearoff=False)
Expand Down Expand Up @@ -435,24 +435,18 @@ def test__extra_help_callback_not_windows(self, mock_openfile):

@mock.patch.object(editor.os, 'startfile')
@unittest.skipIf(not sys.platform.startswith('win'), 'this is test for windows system')
def test__extra_help_callback_windows(self, mock_openfile):
def test_extra_help_callback_windows(self, mock_start):
# os.startfile doesn't exist on other platforms.
w = self.mock_editwin
ehc = partial(w._EditorWindow__extra_help_callback, w)

w.showerror = mock.Mock()
def ehc(source):
return Editor._extra_help_callback(w, source)
ehc('http://python.org')
mock_openfile.called_with('http://python.org')
ehc('www.python.org')
mock_openfile.called_with('www.python.org')
# Filename that opens successfully.
mock_openfile.return_value = True
ehc('/foo/bar/baz/')
mock_openfile.called_with('\\foo\\bar\\baz')
mock_start.called_with('http://python.org')
# Filename that doesn't open.
mock_openfile.return_value = False
with self.assertRaises(OSError):
ehc('/foo/bar/baz/')
self.assertEqual(w.showerror.title, 'Document Start Failure')
mock_start.side_effect = OSError('boom')
ehc('/foo/bar/baz/')()
self.assertTrue(w.showerror.callargs.kwargs)


class BindingsTest(unittest.TestCase):
Expand Down