{
  "id": "python/pytest-skipif-string-evaluated-true",
  "signature": "SKIPPED [1] tests/test_api.py:10: 'sys.platform == \"win32\"'",
  "signature_zh": "已跳过 [1] tests/test_api.py:10: 'sys.platform == \"win32\"'",
  "regex": "SKIPPED\\ \\[1\\]\\ tests/test_api\\.py:10:\\ 'sys\\.platform\\ ==\\ \"win32\"'",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "`@pytest.mark.skipif(\"sys.platform == 'win32'\")` was passed a string, which pytest evaluates in its own namespace; if `sys` is not imported there, the expression may raise or be treated as truthy, skipping on all platforms.",
  "root_cause_type": "generic",
  "root_cause_zh": "`@pytest.mark.skipif(\"sys.platform == 'win32'\")` 传入的是字符串，pytest 在自己的命名空间中求值；如果那里未导入 `sys`，表达式可能报错或被视为真值，导致所有平台都被跳过。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The skipif expression is evaluated at collection time in the marker namespace, not inside the test body.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Skips unconditionally on every platform, permanently disabling the test.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.96,
      "how": "import sys\nimport pytest\n\n@pytest.mark.skipif(sys.platform == \"win32\", reason=\"POSIX only\")\ndef test_symlink():\n    ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "import sys\nimport pytest\n\n@pytest.mark.skipif(lambda: sys.platform == \"win32\", reason=\"POSIX only\")\ndef test_symlink():\n    ...",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}