{
  "id": "python/pytest-collection-error-syntax-in-test",
  "signature": "ERROR collecting tests/test_models.py\n  File \"tests/test_models.py\", line 3\n    def test_model(:\n                  ^\nSyntaxError: invalid syntax",
  "signature_zh": "收集 tests/test_models.py 时出错\n  File \"tests/test_models.py\", 行 3\n    def test_model(:\n                  ^\nSyntaxError: 无效语法",
  "regex": "ERROR\\ collecting\\ tests/test_models\\.py\\\n\\ \\ File\\ \"tests/test_models\\.py\",\\ line\\ 3\\\n\\ \\ \\ \\ def\\ test_model\\(:\\\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\^\\\nSyntaxError:\\ invalid\\ syntax",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A syntax error in a test module (or a module it imports) prevents pytest from collecting it. The error aborts collection for the whole file, so other tests in that file never run.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试模块（或它导入的模块）中的语法错误导致 pytest 无法收集它。该错误会中止整个文件的收集，因此该文件中的其他测试永远不会运行。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Lets other files run but the broken file still contributes zero tests, silently reducing coverage.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The tests in that file are permanently skipped; the syntax error is never fixed.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "python -m py_compile tests/test_models.py && pytest tests/test_models.py",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ruff check tests/ && pytest",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-07",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}