python type_error ai_generated true

TypeError: skip() missing required positional argument: 'reason'

ID: python/unittest-skip-decorator-syntax

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2026-03-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.9 active

Root Cause

Using @unittest.skip without providing a reason string, or using it as a bare decorator without parentheses, causing a TypeError.

generic

中文

使用 @unittest.skip 时未提供原因字符串,或将其作为无括号的裸装饰器使用,导致 TypeError。

Workarounds

  1. 95% success
    Use @unittest.skip('reason') with a string argument, e.g., @unittest.skip('Not implemented yet')
  2. 90% success
    Alternatively, use @unittest.skipIf(condition, 'reason') to skip conditionally.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Adding parentheses but no argument (e.g., @unittest.skip()) still fails because reason is required.

  2. 60% fail

    Using @unittest.skipIf(condition) without a reason also fails because reason is required for skipIf.