# ImportError: Start directory 'tests' is not importable: 'tests' is not a package

- **ID:** `python/unittest-testloader-discover-error`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

When using unittest.TestLoader().discover('tests'), the directory must be a Python package (containing __init__.py) and importable from the current Python path.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Add an empty __init__.py file to the 'tests' directory to make it a package, then run discovery from the parent directory.
   ```
2. **** (80% success)
   ```
   Use a relative path or run the test script from the parent directory of 'tests' to ensure proper import resolution.
   ```

## Dead Ends

- **** — Adding sys.path.append('.') may fix the import but is a fragile workaround that can cause other import issues. (50% fail)
- **** — Changing the discovery pattern (e.g., 'test*.py') without fixing the package structure still fails if the directory is not a package. (60% fail)
