python
type_error
ai_generated
true
TypeError: skip() takes exactly 1 argument (0 given)
ID: python/unittest-skip-decorator-error
80%Fix Rate
90%Confidence
0Evidence
2024-04-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
Root Cause
在unittest中,@unittest.skip装饰器必须提供一个原因字符串,如果省略则报错。
generic中文
在unittest中,@unittest.skip装饰器必须提供一个原因字符串,如果省略则报错。
Workarounds
-
100% success
@unittest.skip('暂时跳过') -
95% success
def test_foo(self): self.skipTest('原因')
Dead Ends
Common approaches that don't work:
-
60% fail
skipIf也需要条件参数,不是无参数跳过
-
70% fail
删除装饰器会导致测试执行,而不是跳过