fix(scaffold): make generated projects pass tests out of the box#93
Merged
Conversation
Six bugs in the cookiecutter scaffold caused `uv run pytest` to fail
immediately after `act new` + `act cast`. After this change, freshly
scaffolded projects produce 4/4 passing tests with no manual edits.
Bug fixes:
1. tests/node_tests/__init.py → __init__.py
Filename typo prevented Python from treating the directory as a
package under strict module discovery.
2. pyproject.toml: add [tool.pytest.ini_options]
Without `pythonpath`/`testpaths`, pytest climbed past fa/ to a
parent pyproject and failed with `ModuleNotFoundError: No module
named 'casts'` for all three test files.
3. SampleNode wrote only `messages`, but OutputState declared only
`result: str` → graph.invoke() returned None. Now writes both
`result` (exposed) and `messages` (accumulated via add_messages),
demonstrating multi-key state updates.
4. Test assertions did not match node output:
- test_node.py asserted {"message": str} (singular) vs actual
{"messages": [AIMessage]}.
- {cast}_test.py asserted result["messages"] == str against a
None result (#3 cascade) → TypeError.
Both updated to match the new node contract.
5. asyncio test support: add `pytest-asyncio` + asyncio_mode="auto"
so async def test_* functions are collected without per-test
decorators.
6. Docstring placeholders hardcoded "Sam"/"Sample Cast"/"sam graphs"
in nodes.py / state.py / middlewares.py / agents.py /
tests/node_tests/test_node.py. Replaced with
`{{ cookiecutter.cast_name }}` so each cast renders correctly.
Verified by regenerating with `python -m act_operator new` +
`act_operator cast` and running `uv run pytest -v`: 4 passed in 0.66s.
`uv run ruff check .` also passes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the scaffold templates to use dynamic cookiecutter variables for the cast name, updates the sample nodes to return both a result and messages payload, and configures pytest-asyncio in pyproject.toml. The test cases have been updated accordingly. The review feedback suggests adding an assertion to verify that the graph invocation result is not None before checking for keys, which prevents less clear TypeError exceptions during test failures.
Two code/config files had Korean comments without language conditioning,
so projects scaffolded with `-l en` still contained Korean text:
- tests/cast_tests/{cast}_test.py: two inline comments added in the
previous commit (regression on my part).
- .pre-commit-config.yaml: three hook description comments hardcoded
in Korean.
In-code/config comments now consistently English per the project
convention (`.env.example`, `README.md`, `TEMPLATE_README.md`, and
`casts/{cast}/README.md` already gate their content on
`cookiecutter.language` and remain language-aware).
Verified by regenerating with `-l en`: `grep -P '[\x{ac00}-\x{d7a3}]'`
returns 0 matches across the generated project, and
`uv run pytest -v` still reports `4 passed in 0.47s`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
qjrm1430
added a commit
that referenced
this pull request
May 27, 2026
Same filename typo as the scaffold one fixed in #93, but in the act_operator package's own test tree. The single-underscore suffix prevented Python from recognising the directory as a package under strict module discovery, which can break tooling that walks the package tree (mypy/pyright in strict mode, some coverage configs). Verified with `uv run pytest -q`: 14 passed in 3.47s. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
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.
🚀 PR Type
faand runninguv run pytest+uv run ruff check .📝 Summary
act new+act cast로 생성된 새 프로젝트가 즉시uv run pytest를 통과하지 못하는 문제 6건 수정. 이 PR 적용 후 갓 스캐폴딩된 프로젝트는 추가 수정 없이 4/4 테스트 통과.📄 Description
act_operator/fa(개발 환경에 생성된 실제 스캐폴드)로 검증 중 다음 결함들을 발견:1.
tests/node_tests/__init.py파일명 오타__init.py(밑줄 1개)__init__.py2.
pyproject.toml에[tool.pytest.ini_options]부재casts모듈 import 실패ModuleNotFoundError: No module named 'casts'collection errorpythonpath = ["."],testpaths = ["tests"],asyncio_mode = "auto"3.
SampleNode와OutputState의미 불일치 → graph.invoke() 항상 NoneSampleNode가{"messages": [AIMessage(...)]}만 반환OutputState는result: str만 선언 → output filter가result만 노출graph.invoke({"query": "test"})→NoneSampleNode가result와messages둘 다 작성 (다중 키 state update 패턴도 시연)4. 테스트 어설션이 노드 출력과 완전 불일치
test_node.py:{"message": "..."}(단수 + str) vs 실제{"messages": [AIMessage]}(복수 + 리스트){cast_snake}_test.py:result["messages"] == "..."는 chore: Design Claude Skills architecture for Act template #3 때문에None["messages"]→TypeError5.
pytest-asyncio미설치 + asyncio_mode 미설정test_async_base_node_calls_execute가async def인데 plugin 없어 collection 실패pytest-asyncio추가 +asyncio_mode = "auto"로 decorator 없이 자동 collection6. "Sam"/"Sample Cast"/"sam graphs" 하드코딩
nodes.py(처음 docstring은 ok),state.py,middlewares.py,agents.py,tests/node_tests/test_node.py{{ cookiecutter.cast_name }}로 템플릿화✅ Quality Checks
uv run ruff check .passed (All checks passed!)uv run pytest -qpassed (4 passed in 0.66s)검증 절차:
💪 Ownership
💡 Notes
act upgrade고려: 기존 프로젝트가act upgrade로 동일 fix를 받을 수 있는지 별도 검증 필요🤖 Generated with Claude Code