# CoverageError: No data collected for module 'my_module'

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

## Root Cause

The coverage plugin (pytest-cov) is not properly configured to measure the target module, often due to missing --cov option or incorrect module path.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **Specify the module to measure using --cov flag.** (95% success)
   ```
   pytest --cov=my_module
   ```
2. **Configure coverage in pyproject.toml under [tool.coverage.run] section.** (90% success)
   ```
   [tool.coverage.run]
source = ['my_module']
   ```

## Dead Ends

- **Adding --cov-report=html without specifying --cov** — Coverage data collection requires --cov to specify the module; without it, no data is collected. (80% fail)
- **Setting coverage in setup.cfg but not using --cov on command line** — Command-line options override config file; if --cov is missing, coverage may not run. (70% fail)
