# pytest-cache：无法写入缓存文件：权限被拒绝

- **ID:** `python/pytest-cache-provider-error`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest 缓存目录没有写入权限，通常因为运行用户或目录权限设置。

## 版本兼容性

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

## 解决方案

1. **修改目录权限** (90% 成功率)
   ```
   chmod -R u+w .pytest_cache
   ```
2. **禁用缓存插件** (85% 成功率)
   ```
   pytest -p no:cacheprovider
   ```

## 无效尝试

- **删除 .pytest_cache** — 尝试删除缓存目录但权限问题依然存在 (50% 失败率)
- **chmod 777** — 尝试修改目录所有者但需要 root 权限 (40% 失败率)
