# PytestUnknownMarkWarning：未知的 pytest.mark.slow —— 这是拼写错误吗？您可以注册自定义标记以避免此警告

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

## 根因

使用了自定义标记（例如 @pytest.mark.slow）但未注册，因此 pytest 发出警告，并且 -m 'slow' 过滤可能无法按预期工作。

## 版本兼容性

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

## 解决方案

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

## 无效尝试

- **** — Silences the warning but -m filtering still doesn't recognize the mark. (80% 失败率)
- **** — -k matches names, not markers; results differ. (70% 失败率)
- **** — Works but duplicates config; pytest.ini is simpler and canonical. (30% 失败率)
