[Bugfix] tests/demo/ is rotted and unrunnable — screens/base.py calls mcrfpy.sceneUI, removed long ago; demos are not in the test suite #372

Closed
opened 2026-07-13 11:28:41 +00:00 by john · 0 comments
Owner

Found while validating the feat/355-grid-input-revival branch against bundled scripts. Pre-existing on master; not caused by that branch.

Defect

tests/demo/demo_main.py dies immediately:

AttributeError: module 'mcrfpy' has no attribute 'sceneUI'. Did you mean: 'Scene'?

The caller is tests/demo/screens/base.py. sceneUI is not exported to the module — verified on both master and the branch:

$ git show master:src/McRFPy_API.cpp | grep -c '"sceneUI"'
0

The C++ function McRFPy_API::_sceneUI still exists (src/McRFPy_API.cpp:1350) and is reachable internally from PySceneObject.cpp:153, but it has no module-level binding. The demo was written against the pre-Scene-object API and was never migrated.

tests/demo/tutorial_showcase.py separately dies with PermissionError: [Errno 13] Permission denied: '/opt/goblincorps' — it writes to a hardcoded absolute path outside the repo.

Why this went unnoticed

tests/run_tests.py does not run anything under tests/demo/. Grep for "demo" in the runner returns nothing. So the demo screens — which CLAUDE.md explicitly points at as the canonical API-usage examples ("Read tests/demo/screens/*.py for correct API usage") — have no CI coverage and have silently bitrotted. demo_main.py was last touched 2026-04-09 (6d5e99a).

That is the real cost here: the documented "look at the demos for correct usage" guidance currently points newcomers at code that does not run.

Suggested fix

  1. Migrate screens/base.py off sceneUI onto the Scene object API (scene.children).
  2. Replace the hardcoded /opt/goblincorps path in tutorial_showcase.py with a temp dir or a repo-relative path.
  3. Add a smoke pass to run_tests.py that executes each demo screen headless and asserts it doesn't raise. Without this, they will rot again — that is the whole reason they rotted the first time.

Item 3 is the one that actually matters; 1 and 2 are one-time cleanups.

Found while validating the `feat/355-grid-input-revival` branch against bundled scripts. **Pre-existing on master; not caused by that branch.** ## Defect `tests/demo/demo_main.py` dies immediately: ``` AttributeError: module 'mcrfpy' has no attribute 'sceneUI'. Did you mean: 'Scene'? ``` The caller is `tests/demo/screens/base.py`. `sceneUI` is **not exported to the module** — verified on both master and the branch: ``` $ git show master:src/McRFPy_API.cpp | grep -c '"sceneUI"' 0 ``` The C++ function `McRFPy_API::_sceneUI` still exists (`src/McRFPy_API.cpp:1350`) and is reachable internally from `PySceneObject.cpp:153`, but it has no module-level binding. The demo was written against the pre-Scene-object API and was never migrated. `tests/demo/tutorial_showcase.py` separately dies with `PermissionError: [Errno 13] Permission denied: '/opt/goblincorps'` — it writes to a hardcoded absolute path outside the repo. ## Why this went unnoticed **`tests/run_tests.py` does not run anything under `tests/demo/`.** Grep for "demo" in the runner returns nothing. So the demo screens — which CLAUDE.md explicitly points at as the *canonical API-usage examples* ("Read `tests/demo/screens/*.py` for correct API usage") — have no CI coverage and have silently bitrotted. `demo_main.py` was last touched 2026-04-09 (6d5e99a). That is the real cost here: the documented "look at the demos for correct usage" guidance currently points newcomers at code that does not run. ## Suggested fix 1. Migrate `screens/base.py` off `sceneUI` onto the `Scene` object API (`scene.children`). 2. Replace the hardcoded `/opt/goblincorps` path in `tutorial_showcase.py` with a temp dir or a repo-relative path. 3. **Add a smoke pass to `run_tests.py`** that executes each demo screen headless and asserts it doesn't raise. Without this, they will rot again — that is the whole reason they rotted the first time. Item 3 is the one that actually matters; 1 and 2 are one-time cleanups.
john closed this issue 2026-07-14 12:01:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#372
No description provided.