All tests fail with 'EXITED with status 3' on pytest 9.2.0 (TestReport._id is not marshallable)
还没有人认领这个 Issue。
评估
调研方向
故障来自 serialize_report(),它在子进程用 marshal.dumps() 发送之前复制了 TestReport.dict。先在 pytest 9.2.0 和 --forked 下用 test_min.py 示例复现问题,然后检查报告字典中哪个值无法被 marshal 序列化。完成的标准是:在 pytest 9.2.0 下使用 --forked 的运行通过;并且当确实发生失败时,子进程的异常会在 os._exit(3) 之前被打印出来。
由索引模型根据 Issue 内容生成。
描述
With pytest 9.2.0, every test run under --forked fails, including ones that pass, with running the test EXITED with status 3. pytest 9.1.1 works.
Reproduce
# test_min.py
def test_ok():
assert True
$ pip install pytest==9.2.0 pytest-forked==1.7.5
$ pytest --forked -q test_min.py
FAILED test_min.py::test_ok - .../test_min.py:1: running the test EXITED with status 3
1 failed
Seen on macOS (Darwin 27.2, Python 3.14.7) and on GitHub's ubuntu-latest and macOS runners.
Cause
pytest 9.2.0 adds a private _id attribute to TestReport, holding a NodeId object. serialize_report() copies rep.__dict__ and the child sends it with marshal.dumps(), which raises ValueError: unmarshallable object on NodeId. The child catches the exception and exits with EXITSTATUS_EXCEPTION (3), so the actual error is never shown.
Checking each value of serialize_report(report) with marshal.dumps shows _id (type NodeId) is the only one that fails under 9.2.0, for the setup, call and teardown reports. There are no failures under 9.1.1.
Possible fix
Drop or stringify values marshal can't handle in serialize_report(), e.g. skip private (_-prefixed) keys, or convert unknown types with str(). pytest-xdist's report serialization goes through config.hook.pytest_report_to_serialize / pytest_report_from_serialized, which pytest keeps compatible. Using those hooks would avoid depending on TestReport.__dict__ at all.
It would also help to print the child's exception (or write it to the stderr capture) before os._exit(3), so the next failure of this kind is self-explanatory.
- 主要语言
- Python
- 星标
- 84
- 派生
- 30
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytest-dev/pytest-forked 的其他 Issue
-
`ResourceWarning`/`PytestUnraisableExceptionWarning` with version 1.7.5可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
pytest-dev/pytest-forked#106 ·
-
难度 1/5 1 小时以内 新手友好度 62/100
pytest-dev/pytest-forked#84 ·
-
难度 5/5 一周以上 新手友好度 20/100
pytest-dev/pytest-forked#111 · 2 条评论 ·
-
Fork per subpath未关闭
难度 4/5 3-5 天 新手友好度 35/100
pytest-dev/pytest-forked#94 ·
-
难度 4/5 3-5 天 新手友好度 30/100
pytest-dev/pytest-forked#88 · 12 条评论 ·
查看 pytest-dev/pytest-forked 的全部 Issue
相似的 Issue
-
Import errors are swallowed: PerthImplicitWatermarker silently becomes None可能已有人在做 @JonRC 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
resemble-ai/Perth#23 ·
-
correction metadata
难度 2/5 1 小时以内 新手友好度 65/100
acl-org/acl-anthology#10753 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
earthtojake/text-to-cad#758 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 70/100
DataTalksClub/faq#545 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复