# 已跳过 [1] tests/test_api.py:10: 'sys.platform == "win32"'

- **ID:** `python/pytest-skipif-string-evaluated-true`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

`@pytest.mark.skipif("sys.platform == 'win32'")` 传入的是字符串，pytest 在自己的命名空间中求值；如果那里未导入 `sys`，表达式可能报错或被视为真值，导致所有平台都被跳过。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (96% 成功率)
   ```
   import sys
import pytest

@pytest.mark.skipif(sys.platform == "win32", reason="POSIX only")
def test_symlink():
    ...
   ```
2. **** (85% 成功率)
   ```
   import sys
import pytest

@pytest.mark.skipif(lambda: sys.platform == "win32", reason="POSIX only")
def test_symlink():
    ...
   ```

## 无效尝试

- **** — The skipif expression is evaluated at collection time in the marker namespace, not inside the test body. (80% 失败率)
- **** — Skips unconditionally on every platform, permanently disabling the test. (90% 失败率)
