◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
7 changes: 4 additions & 3 deletions Lib/idlelib/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ def transform_children(child_dict, modname=None):
The dictionary maps names to pyclbr information objects.
Filter out imported objects.
Augment class names with bases.
Sort objects by line number.

The current tree only calls this once per child_dic as it saves
TreeItems once created. A future tree and tests might violate this,
so a check prevents multiple in-place augmentations.
"""
Expand All @@ -51,7 +52,7 @@ def transform_children(child_dict, modname=None):
supers.append(sname)
obj.name += '({})'.format(', '.join(supers))
obs.append(obj)
return sorted(obs, key=lambda o: o.lineno)


class ModuleBrowser:
Expand Down
28 changes: 14 additions & 14 deletions Lib/idlelib/idle_test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ def test_close(self):
# Nested tree same as in test_pyclbr.py except for supers on C0. C1.
mb = pyclbr
module, fname = 'test', 'test.py'
f0 = mb.Function(module, 'f0', fname, 1)
f1 = mb._nest_function(f0, 'f1', 2)
f2 = mb._nest_function(f1, 'f2', 3)
c1 = mb._nest_class(f0, 'c1', 5)
C0 = mb.Class(module, 'C0', ['base'], fname, 6)
F1 = mb._nest_function(C0, 'F1', 8)
C1 = mb._nest_class(C0, 'C1', 11, [''])
C2 = mb._nest_class(C1, 'C2', 12)
F3 = mb._nest_function(C2, 'F3', 14)
mock_pyclbr_tree = {'f0': f0, 'C0': C0}

# Adjust C0.name, C1.name so tests do not depend on order.
browser.transform_children(mock_pyclbr_tree, 'test') # C0(base)
Expand All @@ -87,12 +87,12 @@ def test_transform_module_children(self):
transform = browser.transform_children
# Parameter matches tree module.
tcl = list(transform(mock_pyclbr_tree, 'test'))
eq(tcl, [f0, C0])
eq(tcl[0].name, 'f0')
eq(tcl[1].name, 'C0(base)')
# Check that second call does not change suffix.
tcl = list(transform(mock_pyclbr_tree, 'test'))
eq(tcl[1].name, 'C0(base)')
# Nothing to traverse if parameter name isn't same as tree module.
tcl = list(transform(mock_pyclbr_tree, 'different name'))
eq(tcl, [])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Toggle all file notes Toggle all file annotations