8000 Squeezer: rename "preview" to "view" · python/cpython@1a1288a · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a1288a

Browse files
committed
Squeezer: rename "preview" to "view"
1 parent 2c795e3 commit 1a1288a

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

Lib/idlelib/idle_test/test_squeezer.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from collections import namedtuple
32
from tkinter import Text
43
import unittest
@@ -250,22 +249,22 @@ def test_expand_last_squeezed_event(self):
250249
self.assertEqual(retval, "break")
251250
self.assertEqual(squeezer.text.bell.call_count, 1)
252251

253-
def test_preview_last_squeezed_event_no_squeezed(self):
254-
"""test the preview_last_squeezed event"""
252+
def test_view_last_squeezed_event_no_squeezed(self):
253+
"""test the view_last_squeezed event"""
255254
# The tested scenario: There are no squeezed texts, therefore there
256-
# are no ExpandingButton instances. The preview_last_squeezed event
255+
# are no ExpandingButton instances. The view_last_squeezed event
257256
# is called and should fail (i.e. call squeezer.text.bell()).
258257
editwin = self.make_mock_editor_window()
259258
squeezer = self.make_squeezer_instance(editwin)
260259

261-
retval = squeezer.preview_last_squeezed_event(event=Mock())
260+
retval = squeezer.view_last_squeezed_event(event=Mock())
262261
self.assertEqual(retval, "break")
263262

264-
def test_preview_last_squeezed_event(self):
265-
"""test the preview_last_squeezed event"""
263+
def test_view_last_squeezed_event(self):
264+
"""test the view_last_squeezed event"""
266265
# The tested scenario: There are two squeezed texts, therefore there
267-
# are two ExpandingButton instances. The preview_last_squeezed event
268-
# is called twice. Both times should call the preview() method of the
266+
# are two ExpandingButton instances. The view_last_squeezed event
267+
# is called twice. Both times should call the view() method of the
269268
# second ExpandingButton.
270269
editwin = self.make_mock_editor_window()
271270
squeezer = self.make_squeezer_instance(editwin)
@@ -274,17 +273,17 @@ def test_preview_last_squeezed_event(self):
274273
squeezer.expandingbuttons = [mock_expandingbutton1,
275274
mock_expandingbutton2]
276275

277-
# check that the second expanding button is previewed
278-
retval = squeezer.preview_last_squeezed_event(event=SENTINEL_VALUE)
276+
# check that the second expanding button is viewed
277+
retval = squeezer.view_last_squeezed_event(event=SENTINEL_VALUE)
279278
self.assertEqual(retval, "break")
280279
self.assertEqual(squeezer.text.bell.call_count, 0)
281-
self.assertEqual(mock_expandingbutton1.preview.call_count, 0)
282-
self.assertEqual(mock_expandingbutton2.preview.call_count, 1)
283-
mock_expandingbutton2.preview.assert_called_with(SENTINEL_VALUE)
280+
self.assertEqual(mock_expandingbutton1.view.call_count, 0)
281+
self.assertEqual(mock_expandingbutton2.view.call_count, 1)
282+
mock_expandingbutton2.view.assert_called_with(SENTINEL_VALUE)
284283

285-
squeezer.preview_last_squeezed_event(event=SENTINEL_VALUE)
286-
self.assertEqual(mock_expandingbutton1.preview.call_count, 0)
287-
self.assertEqual(mock_expandingbutton2.preview.call_count, 2)
284+
squeezer.view_last_squeezed_event(event=SENTINEL_VALUE)
285+
self.assertEqual(mock_expandingbutton1.view.call_count, 0)
286+
self.assertEqual(mock_expandingbutton2.view.call_count, 2)
288287

289288
def test_auto_squeeze(self):
290289
"""test that the auto-squeezing creates an ExpandingButton properly"""
@@ -565,16 +564,16 @@ def test_copy(self):
565564
self.assertEqual(expandingbutton.clipboard_append.call_count, 1)
566565
expandingbutton.clipboard_append.assert_called_with('TEXT')
567566

568-
def test_preview(self):
569-
"""test the preview event"""
567+
def test_view(self):
568+
"""test the view event"""
570569
squeezer = self.make_mock_squeezer()
571570
expandingbutton = ExpandingButton('TEXT', 'TAGS', 50, squeezer)
572571
expandingbutton.selection_own = Mock()
573572

574573
with patch('idlelib.squeezer.view_text', autospec=view_text)\
575574
as mock_view_text:
576-
# trigger the preview event
577-
expandingbutton.preview(event=Mock())
575+
# trigger the view event
576+
expandingbutton.view(event=Mock())
578577

579578
# check that the expanding button called view_text
580579
self.assertEqual(mock_view_text.call_count, 1)

Lib/idlelib/squeezer.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class ExpandingButton(tk.Button):
9999
100100
These buttons are displayed inside a Tk Text widget in place of text. A
101101
user can then use the button to replace it with the original text, copy
102-
the original text to the clipboard or preview the original text in a
103-
separate window.
102+
the original text to the clipboard or view the original text in a separate
103+
window.
104104
105105
Each button is tied to a Squeezer instance, and it knows to update the
106106
Squeezer instance when it is expanded (and therefore removed).
@@ -168,7 +168,7 @@ def expand(self, event=None):
168168
message="\n\n".join([
169169
"The squeezed output is very long: %d lines, %d chars.",
170170
"Expanding it could make IDLE slow or unresponsive.",
171-
"It is recommended to preview or copy the output instead.",
171+
"It is recommended to view or copy the output instead.",
172172
"Really expand?"
173173
]) % (self.numoflines, len(self.s)),
174174
default=tkMessageBox.CANCEL,
@@ -188,8 +188,8 @@ def copy(self, event=None):
188188
self.clipboard_clear()
189189
self.clipboard_append(self.s)
190190

191-
def preview(self, event=None):
192-
"""preview event handler
191+
def view(self, event=None):
192+
"""view event handler
193193
194194
View the original text in a separate text viewer window.
195195
"""
@@ -198,7 +198,7 @@ def preview(self, event=None):
198198
rmenu_specs = (
199199
9E81 # item structure: (label, method_name)
200200
('copy', 'copy'),
201-
('preview', 'preview'),
201+
('view', 'view'),
202202
)
203203

204204
def context_menu_event(self, event):
@@ -329,16 +329,16 @@ def expand_last_squeezed_event(self, event):
329329
self.text.bell()
330330
return "break"
331331

332-
def preview_last_squeezed_event(self, event):
333-
"""preview-last-squeezed event handler
332+
def view_last_squeezed_event(self, event):
333+
"""view-last-squeezed event handler
334334
335335
Preview the last squeezed text in the Text widget.
336336
337337
If there is no such squeezed text, give the user a small warning and
338338
do nothing.
339339
"""
340340
if len(self.expandingbuttons) > 0:
341-
self.expandingbuttons[-1].preview(event)
341+
self.expandingbuttons[-1].view(event)
342342
else:
343343
self.text.bell()
344344
return "break"

0 commit comments

Comments
 (0)
0