Skip to content

tests/test_shape_doctor.py and tests/test_windows_paths.py load templates/family-root/scripts/bootstrap.py and siblings.py with exec_module, which leaves .pyc files inside the template tree, so a test that reads every file under templates/family-root would pass or fail by test order (the failure #456's CI hit for the assembly root) #469

Closed as not planned

Description

@brettheap

Lane: openreposhape-5 (openRepoShape-5)

(lane openRepoShape-5, 2026-10-12T20:35:41Z)

What is wrong. On main (ec8e09a), two fixtures load the family root's scripts by path:

  • tests/test_shape_doctor.py:438-452
  • tests/test_windows_paths.py:80-92

Each calls importlib.util.spec_from_file_location(...) and then spec.loader.exec_module(...) on templates/family-root/scripts/bootstrap.py and templates/family-root/scripts/siblings.py. SourceFileLoader caches bytecode, so the run leaves templates/family-root/scripts/__pycache__/*.cpython-3XX.pyc inside the template tree. .gitignore ignores __pycache__/, so git status never shows it.

Why it matters. PR #456's CI run 38297896001 failed in exactly this way for the assembly root, on Linux and on macOS. Its new test loaded templates/assembly-root/scripts/bootstrap.py the same way. tests/test_scaffold_leg_path_collisions.py runs later, reads every file under templates/assembly-root as UTF-8, met the .pyc and raised UnicodeDecodeError, so 3 tests failed. #456 fixed its own loader: sys.dont_write_bytecode is set around exec_module and restored in a finally, and a test checks that loading a root leaves the template tree unchanged.

Nothing reads every file under templates/family-root after these two fixtures today. tests/test_repo_hygiene.py skips __pycache__ and runs earlier, and the two test_the_paths_refused_are_the_paths_the_materializer_writes tests read templates/assembly-root only. So the suite is green by test order and scope. A test that reads the family root's files the way those tests read the assembly root's would fail whenever it runs after tests/test_shape_doctor.py.

The fix. Do what #456 did, in both fixtures: set sys.dont_write_bytecode = True around each exec_module and restore the old value in finally. A shared helper in tests/conftest.py, used by these fixtures and by #456's load(), would keep one copy of the rule. Add a test like #456's: snapshot every path under templates/, run the loader, and assert the snapshot is unchanged.

Activity

  1. brettheap commented on Oct 12, 2026

    @brettheap
    ContributorAuthor

    Lane: openreposhape-5 (openRepoShape-5)

    (lane openRepoShape-5, 2026-10-12T21:27Z) Moved to #461's checklist (#461 (comment)). Brett Heap ruled on 2026-10-12 that a new edge case found in review goes on its area's checklist rather than into a new issue. This lane filed this one before reading that ruling. It is outside v1.0.0's scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions