# pytest 使用错误：未知标记 'slow' - 也许你的意思是 'slow_test'？

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

## 根因

测试使用了未在 pytest.ini 或 conftest.py 中注册的自定义标记（如 @pytest.mark.slow），导致 pytest 在过滤或运行带有该标记的测试时引发错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.10 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Register the marker in pytest.ini: [pytest] markers = slow: marks tests as slow, or in conftest.py: def pytest_configure(config): config.addinivalue_line('markers', 'slow: marks tests as slow')
   ```
2. **** (70% 成功率)
   ```
   Use the marker without filtering by running pytest with -k 'not slow' to skip unregistered markers, but registration is recommended.
   ```

## 无效尝试

- **** — Ignoring the marker and running all tests without filtering may work but defeats the purpose of selective test execution. (50% 失败率)
- **** — Using a similar built-in marker like @pytest.mark.skip may not achieve the desired filtering behavior. (60% 失败率)
