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

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

## 根因

测试使用了未在 pytest.ini/pyproject.toml 中注册的自定义标记。Pytest 仍会应用该标记但发出警告，启用 strict-markers 后会变成错误。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
markers = [
  "slow: marks tests as slow (deselect with '-m \"not slow\"')",
  "integration: requires external services",
]
   ```
2. **** (95% 成功率)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
addopts = "--strict-markers"
markers = ["slow: slow tests"]
   ```

## 无效尝试

- **** — Silences the warning but the mark remains unregistered; --strict-markers still errors and typo'd marks silently pass. (85% 失败率)
- **** — Loses the ability to select/exclude the test via -m; CI's 'pytest -m "not slow"' no longer filters it. (75% 失败率)
