# pytest_dependency: Cycle detected in dependencies: test_a -> test_b -> test_a

- **ID:** `python/pytest-dependency-cycle`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Two or more tests are marked with @pytest.mark.dependency such that they depend on each other, creating a circular dependency that cannot be resolved.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   @pytest.fixture
def shared_setup():
    # Common setup
    return resource

def test_a(shared_setup):
    pass

def test_b(shared_setup):
    pass
   ```
2. **** (88% success)
   ```
   @pytest.fixture(scope='session')
def shared_state():
    return {}

@pytest.mark.dependency()
def test_a(shared_state):
    shared_state['a'] = True

@pytest.mark.dependency(depends=['test_a'])
def test_b(shared_state):
    assert shared_state['a']
   ```

## Dead Ends

- **** — This breaks the intended test order and may cause other tests to fail or run out of order. (80% fail)
- **** — pytest-ordering does not support dependency tracking and may still run tests in an invalid order. (85% fail)
