8000 bpo-1529353: IDLE: squeeze large output in the shell by taleinat · Pull Request #7626 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-1529353: IDLE: squeeze large output in the shell #7626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a7e130a
bpo-1529353: update the Squeezer extension and its tests
taleinat Jun 11, 2018
0af6a62
bpo-1529353: use idlelib.textview for previewing squeezed output
taleinat Aug 12, 2018
71fb2c1
Merge branch 'master' into bpo-1529353
taleinat Aug 12, 2018
bda6572
Refactor Squeezer from an extension to an integral part of IDLE.
taleinat Aug 13, 2018
53e74d9
Merge branch 'master' into bpo-1529353
taleinat Aug 27, 2018
902091e
Update Squeezer's tests given the latest changes
taleinat Aug 27, 2018
6d7035b
add ability to control text wrapping in IDLE's text viewer
taleinat Aug 28, 2018
45fb1a6
ask for user confirmation before expanding huge squeezed outputs
taleinat Aug 28, 2018
18106e8
increase Squeezer's default auto-squeeze-min-lines from 30 to 50
taleinat Aug 28, 2018
2c795e3
move 'copy' and 'preview' squeezed output actions to a context menu
taleinat Aug 28, 2018
1a1288a
Squeezer: rename "preview" to "view"
taleinat Aug 28, 2018
f753b37
Squeezer: remove tooltip configuration options (delay set to 80ms)
taleinat Aug 30, 2018
6087d3f
Squeezer: remove expand/view-last-squeezed events
taleinat Aug 30, 2018
b7d27cb
Squeezer: make view window non-modal and add horizontal scrollbar
taleinat Aug 30, 2018
ce07987
Merge remote-tracking branch 'origin/master' into pr_7626.
terryjreedy Sep 25, 2018
9676991
Correct error in merge resolution.
terryjreedy < 8000 relative-time datetime="2018-09-25T02:21:59Z" class="no-wrap">Sep 25, 2018
e768e0f
Make test_squeezer runnable.
terryjreedy Sep 25, 2018
fcc9084
bpo-1529353: explicitly create root Tk() objects in tests
taleinat Sep 25, 2018
468d9ec
bpo-1529353: reformat doc-strings as PEP8 and rename test classes
taleinat Sep 25, 2018
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
Squeezer: remove expand/view-last-squeezed events
  • Loading branch information
taleinat committed Aug 30, 2018
commit 6087d3f604623c0b402de0304505f02eb48d9032
92 changes: 0 additions & 92 deletions Lib/idlelib/idle_test/test_squeezer.py
< 8000 td class="blob-code blob-code-deletion js-file-line"> retval = squeezer.expand_last_squeezed_event(event=Mock())
Original file line number Diff line number Diff line change
Expand Up @@ -193,98 +193,6 @@ def test_write_stdout(self):
self.assertEqual(orig_write.call_count, 0)
self.assertEqual(len(squeezer.expandingbuttons), 1)

def test_expand_last_squeezed_event_no_squeezed(self):
"""test the expand_last_squeezed event"""
# The tested scenario: There are no squeezed texts, therefore there
# are no ExpandingButton instances. The expand_last_squeezed event
# is called and should fail (i.e. call squeezer.text.bell()).
editwin = self.make_mock_editor_window()
squeezer = self.make_squeezer_instance(editwin)

retval = squeezer.expand_last_squeezed_event(event=Mock())
self.assertEqual(retval, "break")
self.assertEqual(squeezer.text.bell.call_count, 1)

def test_expand_last_squeezed_event(self):
"""test the expand_last_squeezed event"""
# The tested scenario: There are two squeezed texts, therefore there
# are two ExpandingButton instances. The expand_last_squeezed event
# is called three times. The first time should expand the second
# ExpandingButton; the second time should expand the first
# ExpandingButton; the third time should fail (i.e. call
# squeezer.text.bell()).
editwin = self.make_mock_editor_window()
squeezer = self.make_squeezer_instance(editwin)
mock_expandingbutton1 = Mock()
mock_expandingbutton2 = Mock()
squeezer.expandingbuttons = [mock_expandingbutton1,
mock_expandingbutton2]

# check that the second expanding button is expanded
retval = squeezer.expand_last_squeezed_event(event=SENTINEL_VALUE)
self.assertEqual(retval, "break")
self.assertEqual(squeezer.text.bell.call_count, 0)
self.assertEqual(mock_expandingbutton1.expand.call_count, 0)
self.assertEqual(mock_expandingbutton2.expand.call_count, 1)
mock_expandingbutton2.expand.assert_called_with(SENTINEL_VALUE)

# normally the expanded ExpandingButton would remove itself from
# squeezer.expandingbuttons, but we used a mock instead
squeezer.expandingbuttons.remove(mock_expandingbutton2)

# check that the first expanding button is expanded
retval = squeezer.expand_last_squeezed_event(event=SENTINEL_VALUE)
self.assertEqual(retval, "break")
self.assertEqual(squeezer.text.bell.call_count, 0)
self.assertEqual(mock_expandingbutton1.expand.call_count, 1)
self.assertEqual(mock_expandingbutton2.expand.call_count, 1)
mock_expandingbutton1.expand.assert_called_with(SENTINEL_VALUE)

# normally the expanded ExpandingButton would remove itself from
# squeezer.expandingbuttons, but we used a mock instead
squeezer.expandingbuttons.remove(mock_expandingbutton1)

# no more expanding buttons -- check that squeezer.text.bell() is called
self.assertEqual(retval, "break")
self.assertEqual(squeezer.text.bell.call_count, 1)

def test_view_last_squeezed_event_no_squeezed(self):
"""test the view_last_squeezed event"""
# The tested scenario: There are no squeezed texts, therefore there
# are no ExpandingButton instances. The view_last_squeezed event
# is called and should fail (i.e. call squeezer.text.bell()).
editwin = self.make_mock_editor_window()
squeezer = self.make_squeezer_instance(editwin)

retval = squeezer.view_last_squeezed_event(event=Mock())
self.assertEqual(retval, "break")

def test_view_last_squeezed_event(self):
"""test the view_last_squeezed event"""
# The tested scenario: There are two squeezed texts, therefore there
# are two ExpandingButton instances. The view_last_squeezed event
# is called twice. Both times should call the view() method of the
# second ExpandingButton.
editwin = self.make_mock_editor_window()
squeezer = self.make_squeezer_instance(editwin)
mock_expandingbutton1 = Mock()
mock_expandingbutton2 = Mock()
squeezer.expandingbuttons = [mock_expandingbutton1,
mock_expandingbutton2]

# check that the second expanding button is viewed
retval = squeezer.view_last_squeezed_event(event=SENTINEL_VALUE)
self.assertEqual(retval, "break")
self.assertEqual(squeezer.text.bell.call_count, 0)
self.assertEqual(mock_expandingbutton1.view.call_count, 0)
self.assertEqual(mock_expandingbutton2.view.call_count, 1)
mock_expandingbutton2.view.assert_called_with(SENTINEL_VALUE)

squeezer.view_last_squeezed_event(event=SENTINEL_VALUE)
self.assertEqual(mock_expandingbutton1.view.call_count, 0)
self.assertEqual(mock_expandingbutton2.view.call_count, 2)

def test_auto_squeeze(self):
"""test that the auto-squeezing creates an ExpandingButton properly"""
requires('gui')
Expand Down
12 changes: 0 additions & 12 deletions Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,21 +856,11 @@ class PyShell(OutputWindow):
("help", "_Help"),
]

# Extend menus
menu_extras = [
('edit', [
None, # Separator
("Expand last squeezed text", "<<expand-last-squeezed>>"),
("Preview last squeezed text", "<<preview-last-squeezed>>"),
]),
]

# Extend right-click context menu
rmenu_specs = OutputWindow.rmenu_specs + [
("Squeeze", "<<squeeze-current-text>>"),
]


# New classes
from idlelib.history import History

Expand All @@ -888,8 +878,6 @@ def __init__(self, flist=None):

OutputWindow.__init__(self, flist, None, None)

self.fill_menus(self.menu_extras)

self.usetabs = True
# indentwidth must be 8 when using tabs. See note in EditorWindow:
self.indentwidth = 8
Expand Down
28 changes: 0 additions & 28 deletions Lib/idlelib/squeezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,34 +294,6 @@ def count_lines(self, s):

return count_lines_with_wrapping(s, linewidth, tabwidth)

def expand_last_squeezed_event(self, event):
"""expand-last-squeezed event handler

Expand the last squeezed text in the Text widget.

If there is no such squeezed text, give the user a small warning and
do nothing.
"""
if len(self.expandingbuttons) > 0:
self.expandingbuttons[-1].expand(event)
else:
self.text.bell()
return "break"

def view_last_squeezed_event(self, event):
"""view-last-squeezed event handler

Preview the last squeezed text in the Text widget.

If there is no such squeezed text, give the user a small warning and
do nothing.
"""
if len(self.expandingbuttons) > 0:
self.expandingbuttons[-1].view(event)
else:
self.text.bell()
return "break"

def squeeze_current_text_event(self, event):
"""squeeze-current-text event handler

Expand Down
0