# Flaky test detected: test_foo failed 2 times, passed 1 time

- **ID:** `python/pytest-flaky-test-rerun-failed`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The test is flaky, meaning it sometimes passes and sometimes fails due to non-deterministic behavior, race conditions, or external dependencies.

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   Look for: random data, time-dependent logic, network calls, shared state, order dependence. Use pytest -p no:randomly to disable random order.
   ```
2. **** (90% success)
   ```
   For random: random.seed(42)
For time: freeze_time or mock datetime.now()
For network: use responses or mock.
   ```

## Dead Ends

- **** — This masks the flakiness and can hide real bugs. (90% fail)
- **** — This stops the test from running and doesn't fix the underlying issue. (80% fail)
