# PytestUnknownMarkWarning: 未知的 pytest.mark.slow - 是否拼写错误？你可以注册自定义标记以避免此警告

- **ID:** `python/pytest-marker-unknown-warning`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用了未在 pytest.ini/pyproject.toml 注册的自定义标记；pytest 发出警告，在 `-W error` 下变为失败。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
markers = [
  "slow: marks tests as slow",
  "integration: requires external services",
]

# then
pytest -m slow
   ```
2. **** (90% 成功率)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
addopts = "--strict-markers"
markers = ["slow: slow tests"]
   ```

## 无效尝试

- **** — Changes test semantics (skips instead of conditionally selecting) and loses filtering capability. (90% 失败率)
- **** — Hides typos in marker names and prevents `--strict-markers` from catching regressions. (70% 失败率)
- **** — Suppresses all warnings, including real deprecations and correctness issues. (95% 失败率)
