# FileNotFoundError: [Errno 2] No such file or directory: 'test_data.csv'

- **ID:** `python/unittest-testloader-filenotfounderror`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A unittest TestCase tries to load a data file using a relative path, but the current working directory is not the test data directory.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Use an absolute path derived from the test file location: `import os; data_path = os.path.join(os.path.dirname(__file__), 'test_data.csv')`
   ```
2. **** (90% success)
   ```
   Place test data in a fixed directory and configure the test runner to always start from the project root.
   ```

## Dead Ends

- **** — This is inefficient and clutters the project; the file might still be missed if the path resolution is inconsistent. (80% fail)
- **** — This can affect other tests running in parallel and cause race conditions or side effects. (70% fail)
