Skip to content

Commit

Permalink
Merge 5e3e8e6 into 8b86d87
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Apr 10, 2020
2 parents 8b86d87 + 5e3e8e6 commit b4aa8a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
Expand Up @@ -129,8 +129,8 @@ def test_objectexplorer_collection_types(objectexplorer, params):
model = editor.obj_tree.model()
# The row for the variable
assert model.rowCount() == 1
# Root row without children
assert model.rowCount(model.index(0, 0)) == 0
# Root row without children: 71 in Python 2, 78 in Python 3
assert model.rowCount(model.index(0, 0)) in [71, 78]
assert model.columnCount() == 11


Expand Down
Expand Up @@ -284,29 +284,27 @@ def _fetchObjectChildren(self, obj, obj_path):
path_strings = []
tree_items = []

# Only populate children for objects without their own editor
if not is_editable_type(obj):
is_attr_list = [False] * len(obj_children)

# Object attributes
# Needed to handle errors while getting object's attributes
# Related with spyder-ide/spyder#6728 and spyder-ide/spyder#9959
for attr_name in dir(obj):
try:
attr_value = getattr(obj, attr_name)
obj_children.append((attr_name, attr_value))
path_strings.append('{}.{}'.format(obj_path, attr_name)
if obj_path else attr_name)
is_attr_list.append(True)
except Exception:
# Attribute could not be get
pass
assert len(obj_children) == len(path_strings), "sanity check"

for item, path_str, is_attr in zip(obj_children, path_strings,
is_attr_list):
name, child_obj = item
tree_items.append(TreeItem(child_obj, name, path_str, is_attr))
is_attr_list = [False] * len(obj_children)

# Object attributes
# Needed to handle errors while getting object's attributes
# Related with spyder-ide/spyder#6728 and spyder-ide/spyder#9959
for attr_name in dir(obj):
try:
attr_value = getattr(obj, attr_name)
obj_children.append((attr_name, attr_value))
path_strings.append('{}.{}'.format(obj_path, attr_name)
if obj_path else attr_name)
is_attr_list.append(True)
except Exception:
# Attribute could not be get
pass
assert len(obj_children) == len(path_strings), "sanity check"

for item, path_str, is_attr in zip(obj_children, path_strings,
is_attr_list):
name, child_obj = item
tree_items.append(TreeItem(child_obj, name, path_str, is_attr))

return tree_items

Expand Down

0 comments on commit b4aa8a4

Please sign in to comment.