# AssertionError: assert 0 == 1 in caplog.records for 'WARNING' level

- **ID:** `python/pytest-caplog-level-mismatch`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The test uses caplog to check log messages but the logging level set in the code under test does not match the expected level, or the logger is not configured correctly.

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   Set the logging level in the test using caplog.set_level(logging.WARNING) before calling the code, and ensure the code logs at that level.
   ```
2. **** (80% success)
   ```
   Check the logger name in the code under test and configure caplog to capture logs from that specific logger: caplog.set_level(logging.WARNING, logger='my_logger')
   ```

## Dead Ends

- **** — Setting caplog.set_level(logging.DEBUG) globally may capture too many logs and mask the specific level issue. (50% fail)
- **** — Ignoring the level and checking for any log message may pass but does not validate the intended behavior. (40% fail)
