# AssertionError: 1 != 2 : Test results depend on execution order

- **ID:** `python/unittest-testcase-ordering-issue`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Tests share mutable state (e.g., a global variable or class attribute) without proper isolation, causing order-dependent failures.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Use setUp() to initialize fresh state for each test: `def setUp(self): self.shared_var = 0`
   ```
2. **** (90% success)
   ```
   Refactor tests to avoid shared state by using local variables or mocks.
   ```

## Dead Ends

- **** — This is a brittle workaround; any change in test discovery order can break tests again. (90% fail)
- **** — setUpClass runs once per class, not per test, so state can still leak between tests. (80% fail)
