# E   pytest.PytestAssertRewriteWarning: Module already imported so cannot be rewritten

- **ID:** `python/pytest-assertion-introspection-error`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A plugin or conftest imports a module before pytest's assertion rewriter can register it, so assert statements in that module are not rewritten and produce poor failure messages.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Register the module for rewriting before any import:

# conftest.py (top)
import pytest
pytest.register_assert_rewrite('myapp.core')

import myapp.core  # after registration
   ```
2. **** (85% success)
   ```
   Avoid importing application modules at conftest top level; import inside fixtures instead.
   ```

## Dead Ends

- **** — The warning is suppressed but assertion rewriting remains disabled for that module. (85% fail)
- **** — Import order still places it after pytest's plugin loading in many cases, so the warning persists. (80% fail)
