# E   ModuleNotFoundError: No module named 'tests.test_utils'

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

## Root Cause

A test module tries to import another test module as a package, but the tests directory is not a package (missing __init__.py) or the import path is incorrect.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   In conftest.py at project root:

import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
   ```
2. **** (95% success)
   ```
   pip install -e .
Then in tests: from mypackage.tests.test_utils import helper
   ```
3. **** (85% success)
   ```
   Create a test_utils package at the project root and import from it:
from test_utils import helper
   ```

## Dead Ends

- **** — This makes tests a package but can cause import conflicts with pytest's rootdir and may break other imports. (60% fail)
- **** — Relative imports only work within packages; if tests is not a package, this fails. (70% fail)
- **** — This is brittle and may not work consistently across different working directories. (80% fail)
