Skip to content

Commit 59b890d

Browse files
committed
testcase: Deprecate SkippedTest exception
'SkipTest' from the stdlib should be preferred for future compatibility. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 9c31fd8 commit 59b890d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

testtools/testcase.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import sys
2222
import types
2323
import unittest
24+
from unittest.case import SkipTest
2425
import warnings
2526

2627
from testtools.compat import reraise
@@ -49,9 +50,15 @@
4950
)
5051

5152

52-
class TestSkipped(Exception):
53+
class TestSkipped(SkipTest):
5354
"""Raised within TestCase.run() when a test is skipped."""
54-
TestSkipped = try_import('unittest.case.SkipTest', TestSkipped)
55+
def __init__(self, *args, **kwargs):
56+
warnings.warn(
57+
'Use SkipTest from unittest instead.',
58+
DeprecationWarning,
59+
stacklevel=2,
60+
)
61+
super().__init__(*args, **kwargs)
5562

5663

5764
class _UnexpectedSuccess(Exception):
@@ -218,7 +225,7 @@ class TestCase(unittest.TestCase):
218225
and an optional list of exception handlers.
219226
"""
220227

221-
skipException = TestSkipped
228+
skipException = SkipTest
222229

223230
run_tests_with = RunTest
224231

@@ -597,7 +604,8 @@ def onException(self, exc_info, tb_label='traceback'):
597604
:seealso addOnException:
598605
"""
599606
if exc_info[0] not in [
600-
self.skipException, _UnexpectedSuccess, _ExpectedFailure]:
607+
self.skipException, _UnexpectedSuccess, _ExpectedFailure,
608+
]:
601609
self._report_traceback(exc_info, tb_label=tb_label)
602610
for handler in self.__exception_handlers:
603611
handler(exc_info)

0 commit comments

Comments
 (0)