# AssertionError: assert 0 == 1
# fails with pytest-randomly, passes with -p no:randomly

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

## Root Cause

pytest-randomly shuffles test order each run; order-dependent tests or shared state cause intermittent failures that were hidden by alphabetical ordering.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   pytest -p randomly --randomly-seed=12345 tests/ -x
# identify the leak, then fix with autouse reset fixture
   ```
2. **** (92% success)
   ```
   @pytest.fixture(autouse=True)
def reset_globals():
    myapp.state.clear()
    yield
    myapp.state.clear()
   ```

## Dead Ends

- **** — Hides order dependencies and lets bugs ship; the same issue will reappear under xdist or CI parallelism. (90% fail)
- **** — Masks the bug for that seed; other seeds still fail and the underlying leak remains. (85% fail)
- **** — Requires pytest-ordering and creates brittle coupling; doesn't fix leaked state. (80% fail)
