# CoverageWarning: 未测量到任何上下文
  warnings.warn("No contexts were measured")

- **ID:** `python/pytest-cov-context-not-configured`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

传入了 `--cov-context=test`，但 coverage 配置未启用动态上下文，或 coverage 版本不支持所请求的上下文模式。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 5.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Enable dynamic contexts in coverage config:
# pyproject.toml
[tool.coverage.run]
dynamic_context = "test_function"
# then run:
pytest --cov=myapp --cov-context=test
   ```
2. **** (85% 成功率)
   ```
   Or set the env var before running:
COVERAGE_DYNAMIC_CONTEXT=test_function pytest --cov=myapp --cov-context=test
   ```

## 无效尝试

- **** — Only affects the failure threshold; contexts still not measured. (85% 失败率)
- **** — Hides the warning but loses per-test coverage reporting that was the goal. (60% 失败率)
