{
  "id": "python/pytest-dependency-cycle",
  "signature": "pytest_dependency: Cycle detected in dependencies: test_a -> test_b -> test_a",
  "signature_zh": "pytest_dependency: 检测到依赖循环: test_a -> test_b -> test_a",
  "regex": "pytest_dependency:\\ Cycle\\ detected\\ in\\ dependencies:\\ test_a\\ \\->\\ test_b\\ \\->\\ test_a",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个或多个测试使用 @pytest.mark.dependency 标记，使得它们相互依赖，形成无法解决的循环依赖。",
  "versions": [
    {
      "version": "0.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This breaks the intended test order and may cause other tests to fail or run out of order.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "pytest-ordering does not support dependency tracking and may still run tests in an invalid order.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "@pytest.fixture\ndef shared_setup():\n    # Common setup\n    return resource\n\ndef test_a(shared_setup):\n    pass\n\ndef test_b(shared_setup):\n    pass",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "@pytest.fixture(scope='session')\ndef shared_state():\n    return {}\n\n@pytest.mark.dependency()\ndef test_a(shared_state):\n    shared_state['a'] = True\n\n@pytest.mark.dependency(depends=['test_a'])\ndef test_b(shared_state):\n    assert shared_state['a']",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}