◐ Shell
reader mode source ↗
Skip to content
Merged
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
16 changes: 12 additions & 4 deletions Doc/library/unittest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ that is broken and will fail, but shouldn't be counted as a failure on a
:class:`TestResult`.

Skipping a test is simply a matter of using the :func:`skip` :term:`decorator`
or one of its conditional variants.

Basic skipping looks like this::

Expand All @@ -531,16 +532,23 @@ Basic skipping looks like this::
# windows specific testing code
pass

This is the output of running the example above in verbose mode::

test_format (__main__.MyTestCase) ... skipped 'not supported in this library version'
test_nothing (__main__.MyTestCase) ... skipped 'demonstrating skipping'
test_windows_support (__main__.MyTestCase) ... skipped 'requires Windows'

----------------------------------------------------------------------
Ran 3 tests in 0.005s

OK (skipped=3)

Classes can be skipped just like methods::

Expand Down Expand Up @@ -568,7 +576,7 @@ the test unless the passed object has a certain attribute::
return lambda func: func
return unittest.skip("{!r} doesn't have {!r}".format(obj, attr))

The following decorators implement test skipping and expected failures:

.. decorator:: skip(reason)

Toggle all file notes Toggle all file annotations