python
runtime_error
ai_generated
true
Skipped: evaluating condition 'sys.platform == "win32"' raised AttributeError: module 'sys' has no attribute 'platform'
ID: python/pytest-skipif-condition-evaluation-error
80%Fix Rate
85%Confidence
0Evidence
2025-06-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
The condition in @pytest.mark.skipif references a non-existent attribute, often due to a typo (e.g., 'platfom' instead of 'platform').
generic中文
@pytest.mark.skipif 中的条件引用了一个不存在的属性,通常是由于拼写错误(例如 'platfom' 而不是 'platform')。
Workarounds
-
95% success
Correct the attribute name: `@pytest.mark.skipif(sys.platform == 'win32', reason='not on Windows')`
-
90% success
Use a function for complex conditions: `def is_win(): return sys.platform == 'win32'; @pytest.mark.skipif(is_win())`
Dead Ends
Common approaches that don't work:
-
80% fail
This may cause the test to run on unsupported platforms and fail.
-
90% fail
The condition string is evaluated at module level; try-except is not supported in that context.