# AssertionError: assert 'original' == 'patched'

- **ID:** `python/pytest-monkeypatch-not-reverting`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

monkeypatch fixture在测试后未正确恢复原始值，导致后续测试受到影响。

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   def test_example(monkeypatch):
    monkeypatch.setattr(module, 'attr', 'patched')
    # 测试结束后自动恢复
   ```
2. **** (90% success)
   ```
   with ExitStack() as stack:
    stack.enter_context(patch('module.attr', 'patched'))
   ```

## Dead Ends

- **** — 容易遗漏，且与monkeypatch机制冲突。 (80% fail)
- **** — pytest的monkeypatch自动处理，手动恢复可能重复。 (70% fail)
