Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion lib/ramble/ramble/test/namespace_trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@ def test_add_single(trie):
assert trie.is_prefix("foo")
assert trie.has_value("foo")
assert trie["foo"] == "bar"
assert not trie.is_leaf("foo")
assert trie.is_leaf("foo")
assert not trie.is_leaf("bar")


def test_add_multiple(trie):
trie["foo.bar"] = "baz"

assert not trie.has_value("foo")
assert trie.is_prefix("foo")
assert not trie.is_leaf("foo")

assert trie.is_prefix("foo.bar")
assert trie.has_value("foo.bar")
assert trie["foo.bar"] == "baz"
assert trie.is_leaf("foo.bar")

assert not trie.is_prefix("foo.bar.baz")
assert not trie.has_value("foo.bar.baz")
assert not trie.is_leaf("foo.bar.baz")


def test_add_three(trie):
Expand All @@ -45,16 +49,20 @@ def test_add_three(trie):

assert trie.is_prefix("foo")
assert not trie.has_value("foo")
assert not trie.is_leaf("foo")

assert trie.is_prefix("foo.bar")
assert not trie.has_value("foo.bar")
assert not trie.is_leaf("foo.bar")

assert trie.is_prefix("foo.bar.baz")
assert trie.has_value("foo.bar.baz")
assert trie["foo.bar.baz"] == "quux"
assert trie.is_leaf("foo.bar.baz")

assert not trie.is_prefix("foo.bar.baz.quux")
assert not trie.has_value("foo.bar.baz.quux")
assert not trie.is_leaf("foo.bar.baz.quux")

# Try to add a second element in a prefix namespace
trie["foo.bar"] = "blah"
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/util/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def is_leaf(self, namespace):
"""True if this namespace has no children in the trie."""
first, _, rest = namespace.partition(self._sep)
if not first:
return bool(self._subspaces)
return not self._subspaces
elif first not in self._subspaces:
return False
else:
Expand Down
Loading