# 操作系统错误：[Errno 2] 没有那个文件或目录：'test_data.csv'

- **ID:** `python/oserror-errno-2-no-such-file`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试尝试打开当前工作目录或指定路径中不存在的文件。

## 版本兼容性

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

## 解决方案

1. **Use relative path with proper test directory** (95% 成功率)
   ```
   import os; filepath = os.path.join(os.path.dirname(__file__), 'test_data.csv')
   ```
2. **Create test data using pytest fixture** (90% 成功率)
   ```
   @pytest.fixture
def test_data():
    return {'key': 'value'}
   ```

## 无效尝试

- **Creating an empty file with same name** — Empty file may cause parsing errors or incorrect test results. (70% 失败率)
- **Hardcoding absolute path** — Absolute paths break portability across different environments. (50% 失败率)
