Skip to content

Commit 5755ce0

Browse files
miss-islingtonLamentXU123hugovk
authored
[3.14] gh-101100: Fix sphinx warnings in library/unittest.rst (GH-140109) (#141853)
Co-authored-by: Weilin Du <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 972aa93 commit 5755ce0

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
@@ -438,7 +438,7 @@ run whether the test method succeeded or not.
438438
Such a working environment for the testing code is called a
439439
:dfn:`test fixture`. A new TestCase instance is created as a unique
440440
test fixture used to execute each individual test method. Thus
441-
:meth:`~TestCase.setUp`, :meth:`~TestCase.tearDown`, and :meth:`~TestCase.__init__`
441+
:meth:`~TestCase.setUp`, :meth:`~TestCase.tearDown`, and :meth:`!TestCase.__init__`
442442
will be called once per test.
443443

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

520520
In some cases, the existing tests may have been written using the :mod:`doctest`
521-
module. If so, :mod:`doctest` provides a :class:`DocTestSuite` class that can
521+
module. If so, :mod:`doctest` provides a :class:`~doctest.DocTestSuite` class that can
522522
automatically build :class:`unittest.TestSuite` instances from the existing
523523
:mod:`doctest`\ -based tests.
524524

@@ -1023,7 +1023,7 @@ Test cases
10231023
additional keyword argument *msg*.
10241024

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

10291029
with self.assertRaises(SomeException) as cm:
@@ -1036,7 +1036,7 @@ Test cases
10361036
Added the ability to use :meth:`assertRaises` as a context manager.
10371037

10381038
.. versionchanged:: 3.2
1039-
Added the :attr:`exception` attribute.
1039+
Added the :attr:`!exception` attribute.
10401040

10411041
.. versionchanged:: 3.3
10421042
Added the *msg* keyword argument when used as a context manager.
@@ -1089,8 +1089,8 @@ Test cases
10891089
additional keyword argument *msg*.
10901090

10911091
The context manager will store the caught warning object in its
1092-
:attr:`warning` attribute, and the source line which triggered the
1093-
warnings in the :attr:`filename` and :attr:`lineno` attributes.
1092+
:attr:`!warning` attribute, and the source line which triggered the
1093+
warnings in the :attr:`!filename` and :attr:`!lineno` attributes.
10941094
This can be useful if the intention is to perform additional checks
10951095
on the warning caught::
10961096

@@ -1430,7 +1430,7 @@ Test cases
14301430
that lists the differences between the sets. This method is used by
14311431
default when comparing sets or frozensets with :meth:`assertEqual`.
14321432

1433-
Fails if either of *first* or *second* does not have a :meth:`set.difference`
1433+
Fails if either of *first* or *second* does not have a :meth:`~frozenset.difference`
14341434
method.
14351435

14361436
.. versionadded:: 3.1
@@ -1638,7 +1638,7 @@ Test cases
16381638
.. method:: asyncSetUp()
16391639
:async:
16401640

1641-
Method called to prepare the test fixture. This is called after :meth:`setUp`.
1641+
Method called to prepare the test fixture. This is called after :meth:`TestCase.setUp`.
16421642
This is called immediately before calling the test method; other than
16431643
:exc:`AssertionError` or :exc:`SkipTest`, any exception raised by this method
16441644
will be considered an error rather than a test failure. The default implementation
@@ -1648,7 +1648,7 @@ Test cases
16481648
:async:
16491649

16501650
Method called immediately after the test method has been called and the
1651-
result recorded. This is called before :meth:`tearDown`. This is called even if
1651+
result recorded. This is called before :meth:`~TestCase.tearDown`. This is called even if
16521652
the test method raised an exception, so the implementation in subclasses may need
16531653
to be particularly careful about checking internal state. Any exception, other than
16541654
:exc:`AssertionError` or :exc:`SkipTest`, raised by this method will be
@@ -1677,7 +1677,7 @@ Test cases
16771677
Sets up a new event loop to run the test, collecting the result into
16781678
the :class:`TestResult` object passed as *result*. If *result* is
16791679
omitted or ``None``, a temporary result object is created (by calling
1680-
the :meth:`defaultTestResult` method) and used. The result object is
1680+
the :meth:`~TestCase.defaultTestResult` method) and used. The result object is
16811681
returned to :meth:`run`'s caller. At the end of the test all the tasks
16821682
in the event loop are cancelled.
16831683

@@ -1798,7 +1798,7 @@ Grouping tests
17981798
returned by repeated iterations before :meth:`TestSuite.run` must be the
17991799
same for each call iteration. After :meth:`TestSuite.run`, callers should
18001800
not rely on the tests returned by this method unless the caller uses a
1801-
subclass that overrides :meth:`TestSuite._removeTestAtIndex` to preserve
1801+
subclass that overrides :meth:`!TestSuite._removeTestAtIndex` to preserve
18021802
test references.
18031803

18041804
.. versionchanged:: 3.2
@@ -1809,10 +1809,10 @@ Grouping tests
18091809
.. versionchanged:: 3.4
18101810
In earlier versions the :class:`TestSuite` held references to each
18111811
:class:`TestCase` after :meth:`TestSuite.run`. Subclasses can restore
1812-
that behavior by overriding :meth:`TestSuite._removeTestAtIndex`.
1812+
that behavior by overriding :meth:`!TestSuite._removeTestAtIndex`.
18131813

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

18171817

18181818
Loading and running tests
@@ -1846,12 +1846,12 @@ Loading and running tests
18461846
.. method:: loadTestsFromTestCase(testCaseClass)
18471847

18481848
Return a suite of all test cases contained in the :class:`TestCase`\ -derived
1849-
:class:`testCaseClass`.
1849+
:class:`!testCaseClass`.
18501850

18511851
A test case instance is created for each method named by
18521852
:meth:`getTestCaseNames`. By default these are the method names
18531853
beginning with ``test``. If :meth:`getTestCaseNames` returns no
1854-
methods, but the :meth:`runTest` method is implemented, a single test
1854+
methods, but the :meth:`!runTest` method is implemented, a single test
18551855
case is created for that method instead.
18561856

18571857

@@ -1898,13 +1898,13 @@ Loading and running tests
18981898
case class will be picked up as "a test method within a test case class",
18991899
rather than "a callable object".
19001900

1901-
For example, if you have a module :mod:`SampleTests` containing a
1902-
:class:`TestCase`\ -derived class :class:`SampleTestCase` with three test
1903-
methods (:meth:`test_one`, :meth:`test_two`, and :meth:`test_three`), the
1901+
For example, if you have a module :mod:`!SampleTests` containing a
1902+
:class:`TestCase`\ -derived class :class:`!SampleTestCase` with three test
1903+
methods (:meth:`!test_one`, :meth:`!test_two`, and :meth:`!test_three`), the
19041904
specifier ``'SampleTests.SampleTestCase'`` would cause this method to
19051905
return a suite which will run all three test methods. Using the specifier
19061906
``'SampleTests.SampleTestCase.test_two'`` would cause it to return a test
1907-
suite which will run only the :meth:`test_two` test method. The specifier
1907+
suite which will run only the :meth:`!test_two` test method. The specifier
19081908
can refer to modules and packages which have not been imported; they will
19091909
be imported as a side-effect.
19101910

@@ -2051,7 +2051,7 @@ Loading and running tests
20512051
Testing frameworks built on top of :mod:`unittest` may want access to the
20522052
:class:`TestResult` object generated by running a set of tests for reporting
20532053
purposes; a :class:`TestResult` instance is returned by the
2054-
:meth:`TestRunner.run` method for this purpose.
2054+
:meth:`!TestRunner.run` method for this purpose.
20552055

20562056
:class:`TestResult` instances have the following attributes that will be of
20572057
interest when inspecting the results of running a set of tests:
@@ -2137,12 +2137,12 @@ Loading and running tests
21372137

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

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

21482148
The following methods of the :class:`TestResult` class are used to maintain
@@ -2462,9 +2462,9 @@ Class and Module Fixtures
24622462
-------------------------
24632463

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

24692469
Similarly if a test is from a different module from the previous test then
24702470
``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
@@ -36,7 +36,6 @@ Doc/library/tkinter.rst
3636
Doc/library/tkinter.scrolledtext.rst
3737
Doc/library/tkinter.ttk.rst
3838
Doc/library/unittest.mock.rst
39-
Doc/library/unittest.rst
4039
Doc/library/urllib.parse.rst
4140
Doc/library/urllib.request.rst
4241
Doc/library/wsgiref.rst

0 commit comments

Comments
 (0)