{
  "id": "python/pytest-collection-failed-syntax",
  "signature": "ERROR collecting tests/test_models.py\nE   SyntaxError: invalid syntax. Perhaps you forgot a comma?\n  tests/test_models.py:42\n    assert user.name == \"alice\" \"bob\"",
  "signature_zh": "收集 tests/test_models.py 时出错\nE   SyntaxError: 无效语法。也许你忘记了一个逗号？\n  tests/test_models.py:42\n    assert user.name == \"alice\" \"bob\"",
  "regex": "ERROR\\ collecting\\ tests/test_models\\.py\\\nE\\ \\ \\ SyntaxError:\\ invalid\\ syntax\\.\\ Perhaps\\ you\\ forgot\\ a\\ comma\\?\\\n\\ \\ tests/test_models\\.py:42\\\n\\ \\ \\ \\ assert\\ user\\.name\\ ==\\ \"alice\"\\ \"bob\"",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A syntax error in a test file prevents pytest from importing it, which aborts collection for that file and shows a collection error rather than a test failure. Often caused by implicit string concatenation, missing commas, or Python 2 syntax.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试文件中的语法错误导致 pytest 无法导入，从而中止该文件的收集并显示收集错误而非测试失败。通常由隐式字符串拼接、缺少逗号或 Python 2 语法引起。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "-x stops on first failure; the syntax error still aborts collection and no tests run.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Lets other files run, but the broken file still contributes zero tests, masking the real problem.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "python -m py_compile tests/test_models.py\n# or\npython -c \"import ast; ast.parse(open('tests/test_models.py').read())\"",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "# Wrong\nassert user.name == \"alice\" \"bob\"\n# Right\nassert user.name in {\"alice\", \"bob\"}",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}