From ee13de8533cb06bf93b9eafbfdea3db4782306d5 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 5 Oct 2026 23:10:52 +0000 Subject: [PATCH] Fix BaseNode.has_children and has_siblings has_children and has_siblings returned the raw node's method instead of calling it, so they were always truthy: a text node claimed to have children, and a node without siblings claimed to have siblings. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Anders Kaseorg --- python/markupever/dom.py | 4 ++-- python/tests/test_dom.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/markupever/dom.py b/python/markupever/dom.py index f3f336e..928ea0b 100644 --- a/python/markupever/dom.py +++ b/python/markupever/dom.py @@ -229,12 +229,12 @@ def last_child(self) -> typing.Optional["BaseNode"]: @property def has_siblings(self) -> bool: """Returns `True` if the node has sibling.""" - return self._raw.has_siblings + return self._raw.has_siblings() @property def has_children(self) -> bool: """Returns `True` if the node has children.""" - return self._raw.has_children + return self._raw.has_children() def tree(self) -> "TreeDom": """Returns the TreeDom instance representing the tree to which this node is connected.""" diff --git a/python/tests/test_dom.py b/python/tests/test_dom.py index 7220e41..02b3491 100644 --- a/python/tests/test_dom.py +++ b/python/tests/test_dom.py @@ -162,8 +162,10 @@ def test_connect_node(): assert p.text(strip=True) == "content 1content 2" assert p.text(separator="\t", strip=True) == "content 1\tcontent 2" - assert text.has_siblings - assert p.has_children + assert text.has_siblings is True + assert p.has_children is True + assert text.has_children is False + assert root.has_siblings is False assert p.tree() == dom assert (