# AssertionError: assert 0 == 1
 +  其中 0 = len(shared_list)

- **ID:** `python/pytest-flaky-test-order-dependency`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试依赖于另一个测试修改的状态，而执行顺序发生变化或测试并行运行。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   @pytest.fixture(autouse=True)
def reset_shared_list():
    shared_list.clear()
    yield
   ```
2. **** (90% 成功率)
   ```
   Replace global variables with fixtures that provide fresh instances per test.
   ```

## 无效尝试

- **** — This is fragile and does not fix the underlying state leakage; tests may still fail in isolation. (70% 失败率)
- **** — This is unreliable and slows down tests. (90% 失败率)
