# ImportError: import file mismatch:
  'test_models.py' imported from /app/tests/unit/test_models.py
  'test_models.py' imported from /app/tests/integration/test_models.py
Hint: make sure your test modules/packages have valid Python names.

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

## Root Cause

Two test files share the same basename but live in different directories without __init__.py files, so pytest's rootdir-based module import collides and the second import fails.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Add __init__.py to each test directory so pytest treats them as packages:

touch tests/unit/__init__.py tests/integration/__init__.py
   ```
2. **** (90% success)
   ```
   Or set import mode globally in pytest.ini:

[pytest]
addopts = --import-mode=importlib
   ```

## Dead Ends

- **** — Removes real test coverage; the collision returns as soon as another same-named file is added. (70% fail)
- **** — Fixes the single run but CI still uses the default mode and fails identically. (75% fail)
