Skip to content

Commit 66576c2

Browse files
miss-islingtonLamentXU123hugovk
authored
[3.13] gh-101100: Fix sphinx warnings in library/unittest.rst (GH-140109) (#141854)
Co-authored-by: Weilin Du <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 66e2b4a commit 66576c2

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

Doc/library/unittest.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ run whether the test method succeeded or not.
443443
Such a working environment for the testing code is called a
444444
:dfn:`test fixture`. A new TestCase instance is created as a unique
445445
test fixture used to execute each individual test method. Thus
446-
:meth:`~TestCase.setUp`, :meth:`~TestCase.tearDown`, and :meth:`~TestCase.__init__`
446+
:meth:`~TestCase.setUp`, :meth:`~TestCase.tearDown`, and :meth:`!TestCase.__init__`
447447
will be called once per test.
448448

449449
It is recommended that you use TestCase implementations to group tests together
@@ -523,7 +523,7 @@ set-up and tear-down methods::
523523
subclasses will make future test refactorings infinitely easier.
524524

525525
In some cases, the existing tests may have been written using the :mod:`doctest`
526-
module. If so, :mod:`doctest` provides a :class:`DocTestSuite` class that can
526+
module. If so, :mod:`doctest` provides a :class:`~doctest.DocTestSuite` class that can
527527
automatically build :class:`unittest.TestSuite` instances from the existing
528528
:mod:`doctest`\ -based tests.
529529

@@ -1013,7 +1013,7 @@ Test cases
10131013
additional keyword argument *msg*.
10141014

10151015
The context manager will store the caught exception object in its
1016-
:attr:`exception` attribute. This can be useful if the intention
1016+
:attr:`!exception` attribute. This can be useful if the intention
10171017
is to perform additional checks on the exception raised::
10181018

10191019
with self.assertRaises(SomeException) as cm:
@@ -1026,7 +1026,7 @@ Test cases
10261026
Added the ability to use :meth:`assertRaises` as a context manager.
10271027

10281028
.. versionchanged:: 3.2
1029-
Added the :attr:`exception` attribute.
1029+
Added the :attr:`!exception` attribute.
10301030

10311031
.. versionchanged:: 3.3
10321032
Added the *msg* keyword argument when used as a context manager.
@@ -1079,8 +1079,8 @@ Test cases
10791079
additional keyword argument *msg*.
10801080

10811081
The context manager will store the caught warning object in its
1082-
:attr:`warning` attribute, and the source line which triggered the
1083-
warnings in the :attr:`filename` and :attr:`lineno` attributes.
1082+
:attr:`!warning` attribute, and the source line which triggered the
1083+
warnings in the :attr:`!filename` and :attr:`!lineno` attributes.
10841084
This can be useful if the intention is to perform additional checks
10851085
on the warning caught::
10861086

@@ -1374,7 +1374,7 @@ Test cases
13741374
that lists the differences between the sets. This method is used by
13751375
default when comparing sets or frozensets with :meth:`assertEqual`.
13761376

1377-
Fails if either of *first* or *second* does not have a :meth:`set.difference`
1377+
Fails if either of *first* or *second* does not have a :meth:`~frozenset.difference`
13781378
method.
13791379

13801380
.. versionadded:: 3.1
@@ -1582,7 +1582,7 @@ Test cases
15821582
.. method:: asyncSetUp()
15831583
:async:
15841584

1585-
Method called to prepare the test fixture. This is called after :meth:`setUp`.
1585+
Method called to prepare the test fixture. This is called after :meth:`TestCase.setUp`.
15861586
This is called immediately before calling the test method; other than
15871587
:exc:`AssertionError` or :exc:`SkipTest`, any exception raised by this method
15881588
will be considered an error rather than a test failure. The default implementation
@@ -1592,7 +1592,7 @@ Test cases
15921592
:async:
15931593

15941594
Method called immediately after the test method has been called and the
1595-
result recorded. This is called before :meth:`tearDown`. This is called even if
1595+
result recorded. This is called before :meth:`~TestCase.tearDown`. This is called even if
15961596
the test method raised an exception, so the implementation in subclasses may need
15971597
to be particularly careful about checking internal state. Any exception, other than
15981598
:exc:`AssertionError` or :exc:`SkipTest`, raised by this method will be
@@ -1621,7 +1621,7 @@ Test cases
16211621
Sets up a new event loop to run the test, collecting the result into
16221622
the :class:`TestResult` object passed as *result*. If *result* is
16231623
omitted or ``None``, a temporary result object is created (by calling
1624-
the :meth:`defaultTestResult` method) and used. The result object is
1624+
the :meth:`~TestCase.defaultTestResult` method) and used. The result object is
16251625
returned to :meth:`run`'s caller. At the end of the test all the tasks
16261626
in the event loop are cancelled.
16271627

@@ -1742,7 +1742,7 @@ Grouping tests
17421742
returned by repeated iterations before :meth:`TestSuite.run` must be the
17431743
same for each call iteration. After :meth:`TestSuite.run`, callers should
17441744
not rely on the tests returned by this method unless the caller uses a
1745-
subclass that overrides :meth:`TestSuite._removeTestAtIndex` to preserve
1745+
subclass that overrides :meth:`!TestSuite._removeTestAtIndex` to preserve
17461746
test references.
17471747

17481748
.. versionchanged:: 3.2
@@ -1753,10 +1753,10 @@ Grouping tests
17531753
.. versionchanged:: 3.4
17541754
In earlier versions the :class:`TestSuite` held references to each
17551755
:class:`TestCase` after :meth:`TestSuite.run`. Subclasses can restore
1756-
that behavior by overriding :meth:`TestSuite._removeTestAtIndex`.
1756+
that behavior by overriding :meth:`!TestSuite._removeTestAtIndex`.
17571757

17581758
In the typical usage of a :class:`TestSuite` object, the :meth:`run` method
1759-
is invoked by a :class:`TestRunner` rather than by the end-user test harness.
1759+
is invoked by a :class:`!TestRunner` rather than by the end-user test harness.
17601760

17611761

17621762
Loading and running tests
@@ -1790,12 +1790,12 @@ Loading and running tests
17901790
.. method:: loadTestsFromTestCase(testCaseClass)
17911791

17921792
Return a suite of all test cases contained in the :class:`TestCase`\ -derived
1793-
:class:`testCaseClass`.
1793+
:class:`!testCaseClass`.
17941794

17951795
A test case instance is created for each method named by
17961796
:meth:`getTestCaseNames`. By default these are the method names
17971797
beginning with ``test``. If :meth:`getTestCaseNames` returns no
1798-
methods, but the :meth:`runTest` method is implemented, a single test
1798+
methods, but the :meth:`!runTest` method is implemented, a single test
17991799
case is created for that method instead.
18001800

18011801

@@ -1842,13 +1842,13 @@ Loading and running tests
18421842
case class will be picked up as "a test method within a test case class",
18431843
rather than "a callable object".
18441844

1845-
For example, if you have a module :mod:`SampleTests` containing a
1846-
:class:`TestCase`\ -derived class :class:`SampleTestCase` with three test
1847-
methods (:meth:`test_one`, :meth:`test_two`, and :meth:`test_three`), the
1845+
For example, if you have a module :mod:`!SampleTests` containing a
1846+
:class:`TestCase`\ -derived class :class:`!SampleTestCase` with three test
1847+
methods (:meth:`!test_one`, :meth:`!test_two`, and :meth:`!test_three`), the
18481848
specifier ``'SampleTests.SampleTestCase'`` would cause this method to
18491849
return a suite which will run all three test methods. Using the specifier
18501850
``'SampleTests.SampleTestCase.test_two'`` would cause it to return a test
1851-
suite which will run only the :meth:`test_two` test method. The specifier
1851+
suite which will run only the :meth:`!test_two` test method. The specifier
18521852
can refer to modules and packages which have not been imported; they will
18531853
be imported as a side-effect.
18541854

@@ -1995,7 +1995,7 @@ Loading and running tests
19951995
Testing frameworks built on top of :mod:`unittest` may want access to the
19961996
:class:`TestResult` object generated by running a set of tests for reporting
19971997
purposes; a :class:`TestResult` instance is returned by the
1998-
:meth:`TestRunner.run` method for this purpose.
1998+
:meth:`!TestRunner.run` method for this purpose.
19991999

20002000
:class:`TestResult` instances have the following attributes that will be of
20012001
interest when inspecting the results of running a set of tests:
@@ -2081,12 +2081,12 @@ Loading and running tests
20812081

20822082
This method can be called to signal that the set of tests being run should
20832083
be aborted by setting the :attr:`shouldStop` attribute to ``True``.
2084-
:class:`TestRunner` objects should respect this flag and return without
2084+
:class:`!TestRunner` objects should respect this flag and return without
20852085
running any additional tests.
20862086

20872087
For example, this feature is used by the :class:`TextTestRunner` class to
20882088
stop the test framework when the user signals an interrupt from the
2089-
keyboard. Interactive tools which provide :class:`TestRunner`
2089+
keyboard. Interactive tools which provide :class:`!TestRunner`
20902090
implementations can use this in a similar manner.
20912091

20922092
The following methods of the :class:`TestResult` class are used to maintain
@@ -2406,9 +2406,9 @@ Class and Module Fixtures
24062406
-------------------------
24072407

24082408
Class and module level fixtures are implemented in :class:`TestSuite`. When
2409-
the test suite encounters a test from a new class then :meth:`tearDownClass`
2410-
from the previous class (if there is one) is called, followed by
2411-
:meth:`setUpClass` from the new class.
2409+
the test suite encounters a test from a new class then
2410+
:meth:`~TestCase.tearDownClass` from the previous class (if there is one)
2411+
is called, followed by :meth:`~TestCase.setUpClass` from the new class.
24122412

24132413
Similarly if a test is from a different module from the previous test then
24142414
``tearDownModule`` from the previous module is run, followed by

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Doc/library/tkinter.rst
3838
Doc/library/tkinter.scrolledtext.rst
3939
Doc/library/tkinter.ttk.rst
4040
Doc/library/unittest.mock.rst
41-
Doc/library/unittest.rst
4241
Doc/library/urllib.parse.rst
4342
Doc/library/urllib.request.rst
4443
Doc/library/wsgiref.rst

0 commit comments

Comments
 (0)