Skip to content

Commit 8364c82

Browse files
author
Michael Foord
committed
Documentation updates for issues 8302 and 8351 (truncating excessive diffs in unittest failure messages and reporting SkipTest exceptions in setUpClass and setUpModule as skips rather than errors).
1 parent 98fd8e9 commit 8364c82

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

Doc/library/unittest.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,21 @@ Test cases
11501150
.. versionadded:: 2.7
11511151

11521152

1153+
.. attribute:: maxDiff
1154+
1155+
This attribute controls the maximum length of diffs output by assert
1156+
methods that report diffs on failure. It defaults to 80*8 characters.
1157+
Assert methods affected by this attribute are
1158+
:meth:`assertSequenceEqual` (including all the sequence comparison
1159+
methods that delegate to it), :meth:`assertDictEqual` and
1160+
:meth:`assertMultiLineEqual`.
1161+
1162+
Setting ``maxDiff`` to None means that there is no maximum length of
1163+
diffs.
1164+
1165+
.. versionadded:: 2.7
1166+
1167+
11531168
Testing frameworks can use the following methods to collect information on
11541169
the test:
11551170

@@ -1848,7 +1863,9 @@ then you must call up to them yourself. The implementations in
18481863

18491864
If an exception is raised during a ``setUpClass`` then the tests in the class
18501865
are not run and the ``tearDownClass`` is not run. Skipped classes will not
1851-
have ``setUpClass`` or ``tearDownClass`` run.
1866+
have ``setUpClass`` or ``tearDownClass`` run. If the exception is a
1867+
``SkipTest`` exception then the class will be reported as having been skipped
1868+
instead of as an error.
18521869

18531870

18541871
setUpModule and tearDownModule
@@ -1863,7 +1880,9 @@ These should be implemented as functions::
18631880
closeConnection()
18641881

18651882
If an exception is raised in a ``setUpModule`` then none of the tests in the
1866-
module will be run and the ``tearDownModule`` will not be run.
1883+
module will be run and the ``tearDownModule`` will not be run. If the exception is a
1884+
``SkipTest`` exception then the module will be reported as having been skipped
1885+
instead of as an error.
18671886

18681887

18691888
Signal Handling

0 commit comments

Comments
 (0)