python type_error ai_generated true

TypeError: skip() takes exactly 1 argument (0 given)

ID: python/unittest-skip-decorator-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-04-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active

Root Cause

在unittest中,@unittest.skip装饰器必须提供一个原因字符串,如果省略则报错。

generic

中文

在unittest中,@unittest.skip装饰器必须提供一个原因字符串,如果省略则报错。

Workarounds

  1. 100% success
    @unittest.skip('暂时跳过')
  2. 95% success
    def test_foo(self):
        self.skipTest('原因')

Dead Ends

Common approaches that don't work:

  1. 60% fail

    skipIf也需要条件参数,不是无参数跳过

  2. 70% fail

    删除装饰器会导致测试执行,而不是跳过