# ERROR collecting tests/test_app.py
ImportError while importing test module '/app/tests/test_app.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
conftest.py:5: in <module>
    from myapp import settings
E   ModuleNotFoundError: No module named 'myapp'

- **ID:** `python/pytest-collection-error-conftest-syntax`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The project root is not on sys.path when pytest runs, so imports in conftest.py or test modules fail. This commonly happens when running pytest from a subdirectory or without installing the package in editable mode.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   pip install -e .
# or with pyproject.toml:
pip install -e '.[test]'
   ```
2. **** (90% success)
   ```
   # pytest.ini or pyproject.toml
[tool.pytest.ini_options]
pythonpath = ['.']
# or CLI: pytest --import-mode=importlib
   ```

## Dead Ends

- **** — Relative paths depend on CWD; running pytest from a different directory breaks it, and conftest.py is imported before test files so the fix is too late. (75% fail)
- **** — Works for interactive runs but is not persisted for CI or IDE test runners, leading to flaky 'works on my machine' behavior. (55% fail)
