bpo-34596: Fallback to a default reason when @unittest.skip is uncalled (#9082)
* bpo-34596: Fallback to a default reason when @unittest.skip is uncalled
* Change default reason to empty string
* Fix rst formatting of NEWS entry
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 8afb845..bac9789 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -10,6 +10,7 @@
import collections
import contextlib
import traceback
+import types
from . import result
from .util import (strclass, safe_repr, _count_diff_all_purpose,
@@ -122,6 +123,10 @@
test_item.__unittest_skip__ = True
test_item.__unittest_skip_why__ = reason
return test_item
+ if isinstance(reason, types.FunctionType):
+ test_item = reason
+ reason = ''
+ return decorator(test_item)
return decorator
def skipIf(condition, reason):