# CoverageWarning: 模块 myapp 从未被导入。(module-not-imported)

- **ID:** `python/pytest-cov-source-not-found`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest-cov 使用 --cov=myapp 调用，但测试会话期间从未导入该包，通常是因为测试导入的包名不同或源码路径错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.x | active | — | — |
| 5.x | active | — | — |
| 6.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   pytest --cov=myapp --cov-report=term-missing tests/
   ```
2. **** (88% 成功率)
   ```
   # .coveragerc
[run]
source = src/myapp
   ```

## 无效尝试

- **** — Changes the report format only; the module is still never imported so coverage stays at 0%. (80% 失败率)
- **** — Marks the module as imported but bypasses the real code paths, producing misleading 100% coverage on empty lines. (70% 失败率)
