Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 184e593

Browse files
committed
#17329: merge with 3.2.
2 parents 768f6a5 + 265281a commit 184e593

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

Doc/library/unittest.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ the test unless the passed object has a certain attribute::
530530
def skipUnlessHasattr(obj, attr):
531531
if hasattr(obj, attr):
532532
return lambda func: func
533-
return unittest.skip("{0!r} doesn't have {1!r}".format(obj, attr))
533+
return unittest.skip("{!r} doesn't have {!r}".format(obj, attr))
534534

535535
The following decorators implement test skipping and expected failures:
536536

@@ -552,6 +552,13 @@ The following decorators implement test skipping and expected failures:
552552
Mark the test as an expected failure. If the test fails when run, the test
553553
is not counted as a failure.
554554

555+
.. exception:: SkipTest(reason)
556+
557+
This exception is raised to skip a test.
558+
559+
Usually you can use :meth:`TestCase.skipTest` or one of the skipping
560+
decorators instead of raising this directly.
561+
555562
Skipped tests will not have :meth:`setUp` or :meth:`tearDown` run around them.
556563
Skipped classes will not have :meth:`setUpClass` or :meth:`tearDownClass` run.
557564

@@ -1958,7 +1965,7 @@ then you must call up to them yourself. The implementations in
19581965
If an exception is raised during a ``setUpClass`` then the tests in the class
19591966
are not run and the ``tearDownClass`` is not run. Skipped classes will not
19601967
have ``setUpClass`` or ``tearDownClass`` run. If the exception is a
1961-
``SkipTest`` exception then the class will be reported as having been skipped
1968+
:exc:`SkipTest` exception then the class will be reported as having been skipped
19621969
instead of as an error.
19631970

19641971

@@ -1975,7 +1982,7 @@ These should be implemented as functions::
19751982

19761983
If an exception is raised in a ``setUpModule`` then none of the tests in the
19771984
module will be run and the ``tearDownModule`` will not be run. If the exception is a
1978-
``SkipTest`` exception then the module will be reported as having been skipped
1985+
:exc:`SkipTest` exception then the module will be reported as having been skipped
19791986
instead of as an error.
19801987

19811988

Lib/unittest/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SkipTest(Exception):
2222
"""
2323
Raise this exception in a test to skip it.
2424
25-
Usually you can use TestResult.skip() or one of the skipping decorators
25+
Usually you can use TestCase.skipTest() or one of the skipping decorators
2626
instead of raising this directly.
2727
"""
2828

0 commit comments

Comments
 (0)