# AssertionError: assert 'foo' == 'bar'  # intermittent

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

## Root Cause

Test depends on ordering or shared mutable state; when run in a different order (e.g., with `-p no:randomly` or xdist), it fails.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   @pytest.fixture
def state():
    return {}

def test_a(state):
    state['x'] = 1
   ```
2. **** (85% success)
   ```
   pytest -p randomly --randomly-seed=12345
   ```

## Dead Ends

- **** — Masks the underlying bug and increases test time; failures may still occur. (70% fail)
- **** — Hides the order dependency but does not fix it; CI may use a different order. (60% fail)
