{
  "id": "python/pytest-collection-error-syntaxerror",
  "signature": "ERROR collecting tests/test_example.py\nE   SyntaxError: invalid syntax",
  "signature_zh": "收集 tests/test_example.py 时出错\nE   SyntaxError: invalid syntax",
  "regex": "ERROR\\ collecting\\ tests/test_example\\.py\\\nE\\ \\ \\ SyntaxError:\\ invalid\\ syntax",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "There is a syntax error in the test file or an imported module, preventing pytest from collecting the test.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试文件或导入的模块中存在语法错误，导致 pytest 无法收集测试。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "pytest cannot collect tests from a file with syntax errors; the test will not run.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This hides the underlying syntax error and may cause other tests to fail if the module is imported elsewhere.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "python -m py_compile tests/test_example.py\nFix the reported syntax error, then rerun pytest.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "flake8 tests/test_example.py\nAddress the reported issues.",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}