Fix (and test) parent-child relationships#66
Merged
gselzer merged 2 commits intopyapp-kit:mainfrom Apr 15, 2026
Merged
Conversation
The main fix here is that passing the parent kwarg to a Node constructor wasn't actually setting the parent. The rest of the tests are just nice to have.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes parent/child bookkeeping in the scene graph by ensuring parent= passed at node construction time results in a consistent parent→children relationship, and adds targeted tests around the Node relationship API.
Changes:
- Add
tests/model/_nodes/test_node.pycovering add/remove child behavior, constructorchildren=andparent=kwargs, reparenting, and__contains__. - Update
Node.__init__to synchronize parent→children whenparentis provided via kwargs. - Prevent duplicate additions in
Node.add_child, and simplify removal typing in_update_parent_children.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/model/_nodes/test_node.py |
New tests validating parent/child invariants, signal emission, and reparenting behavior. |
src/scenex/model/_nodes/node.py |
Fix constructor-time parent= handling; add dedupe logic in add_child; adjust _update_parent_children removal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
==========================================
+ Coverage 88.13% 88.38% +0.24%
==========================================
Files 62 62
Lines 2950 3064 +114
==========================================
+ Hits 2600 2708 +108
- Misses 350 356 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main fix here is that passing the parent kwarg to a Node constructor wasn't actually setting the parent. The rest of the tests are just nice to have.