python type_error ai_generated true

类型错误:skip() 恰好接受一个参数(给定 0 个)

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

ID: python/unittest-skip-decorator-not-working

其他格式: JSON · Markdown 中文 · English
80%修复率
88%置信度
0证据数
2024-11-05首次发现

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

使用 @unittest.skip 而没有提供原因字符串。

English

Using @unittest.skip without a reason string.

generic

解决方案

  1. 99% 成功率
    @unittest.skip('reason for skipping')
    def test_foo(self):
        ...
  2. 98% 成功率
    @pytest.mark.skip(reason='reason for skipping')

无效尝试

常见但无效的做法:

  1. 90% 失败

    skip is a function that requires a reason argument.

  2. 80% 失败

    skipIf requires two arguments: condition and reason.