# import file mismatch:
  /proj/tests/test_a.py has __pycache__ ...
  imported module 'test_a' has this __file__ attribute:
    /proj/tests/sub/test_a.py

- **ID:** `python/pytest-import-file-mismatch`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Two test files share the same basename in different directories without __init__.py, so Python's module cache collides on the module name 'test_a'.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   touch tests/__init__.py tests/sub/__init__.py
# then rerun: pytest -q
   ```
2. **** (90% success)
   ```
   # pytest.ini
[pytest]
addopts = --import-mode=importlib
   ```
3. **** (85% success)
   ```
   mv tests/test_a.py tests/test_alpha.py
mv tests/sub/test_a.py tests/sub/test_a_sub.py
   ```

## Dead Ends

- **** — Cache regeneration recreates the same collision on the next run. (90% fail)
- **** — Hash randomization is unrelated to module name resolution. (95% fail)
- **** — May work short-term but the same pattern recurs as the suite grows. (40% fail)
