Skip to content

Commit

Permalink
BUG: Parent attribute not present past items in root group (#749)
Browse files Browse the repository at this point in the history
* BUG: Only append slash for root when accessing parent

* TST: Add nested collection parent test

* Fix test
  • Loading branch information
ksunden authored and untzag committed Sep 20, 2018
1 parent 5829bf4 commit 3e701be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion WrightTools/_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def parent(self):
except (AssertionError, AttributeError):
from .collection import Collection

key = posixpath.dirname(self.fullpath) + posixpath.sep
key = posixpath.dirname(self.fullpath)
if key.endswith("::"):
key += posixpath.sep
self._parent = Collection._instances[key]
finally:
return self._parent
Expand Down
2 changes: 2 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def test_named_root_data():
def test_parent_child():
parent = wt.Collection(name="mother")
child = wt.Collection(parent=parent, name="goose")
grandchild = wt.Collection(parent=child, name="hen")
assert child.filepath == parent.filepath
assert child.parent is parent
assert grandchild.parent is child


def test_single_instance_collection():
Expand Down

0 comments on commit 3e701be

Please sign in to comment.