来源信息
- 仓库
- ethereum/execution-specs
- 最近来源活动
- 2026年9月3日 10:31
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 1,207
- Forks
- 528
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
正在显示 SKILL.md
SKILL.md
来源说明 · 只读预览- name
- pytester
- description
- Write and run isolated pytester-based plugin tests.
# Pytester
Guide for pytester-based plugin/CLI tests. Run before writing or modifying these tests.
## Which execution mode to use
- **`runpytest()`** — default. In-process, fast, full `RunResult` API (`assert_outcomes()`, `fnmatch_lines()`).
- **`runpytest_subprocess()`** — use only when in-process causes state leakage (Pydantic cache pollution, global mutation in `pytest_configure`). Same `RunResult` API.
- **Raw `subprocess.run()`** — never use alongside pytester. Use `runpytest_subprocess()` instead.
Subprocess isolation masks bugs rather than fixing them. Prefer fixing the root cause and use subprocess as defense-in-depth.
## Expected inner failures
`runpytest_subprocess()` replays inner output to outer stdout (by design). Suppress with `capsys.readouterr()`:
```python
def test_expected_failure(pytester: Any, capsys: Any, pytestconfig: Any) -> None:
result = pytester.runpytest_subprocess(...)
capsys.readouterr() # suppress inner failure bleed
assert result.ret != 0
output = "\n".join(result.outlines + result.errlines)
# conditional print for -s debugging
if pytestconfig.getoption("capture") == "no":
with capsys.disabled():
print(output)
```
## RunResult API
Prefer `assert_outcomes()` and `fnmatch_lines()` over manual `any(... in line ...)` — better failure messages.
- `result.ret` — exit code
- `result.outlines` / `result.errlines` — line lists
- `result.assert_outcomes(passed=N, failed=N)`
- `result.stdout.fnmatch_lines(["*pattern*"])`
在 GitHub 查看