From dea59cf88adf5d20812edda330e085a4695baba4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 18 Sep 2021 15:34:22 +0300 Subject: bpo-36674: Honour the skipping decorators in TestCase.debug() (GH-28446) unittest.TestCase.debug() raises now a SkipTest if the class or the test method are decorated with the skipping decorator. Previously it only raised a SkipTest if the test method was decorated with other decorator in addition to the skipping decorator, or if SkipTest was explicitly raised in the test or setup methods. --- Lib/unittest/case.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Lib/unittest/case.py') diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index e2f0ed3289..9fbf8524fc 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -653,8 +653,16 @@ class TestCase(object): def debug(self): """Run the test without collecting errors in a TestResult""" + testMethod = getattr(self, self._testMethodName) + if (getattr(self.__class__, "__unittest_skip__", False) or + getattr(testMethod, "__unittest_skip__", False)): + # If the class or method was skipped. + skip_why = (getattr(self.__class__, '__unittest_skip_why__', '') + or getattr(testMethod, '__unittest_skip_why__', '')) + raise SkipTest(skip_why) + self.setUp() - getattr(self, self._testMethodName)() + testMethod() self.tearDown() while self._cleanups: function, args, kwargs = self._cleanups.pop(-1) -- cgit v1.2.1