Skip to content

Commit d4e3829

Browse files
LamentXU123hugovk
andauthored
gh-101100: Fix sphinx warnings in library/unittest.rst (#140109)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 58badb1 commit d4e3829

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

@@ -1437,7 +1437,7 @@ Test cases
14371437
that lists the differences between the sets. This method is used by
14381438
default when comparing sets or frozensets with :meth:`assertEqual`.
14391439

1440-
Fails if either of *first* or *second* does not have a :meth:`set.difference`
1440+
Fails if either of *first* or *second* does not have a :meth:`~frozenset.difference`
14411441
method.
14421442

14431443
.. versionadded:: 3.1
@@ -1645,7 +1645,7 @@ Test cases
16451645
.. method:: asyncSetUp()
16461646
:async:
16471647

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

16571657
Method called immediately after the test method has been called and the
1658-
result recorded. This is called before :meth:`tearDown`. This is called even if
1658+
result recorded. This is called before :meth:`~TestCase.tearDown`. This is called even if
16591659
the test method raised an exception, so the implementation in subclasses may need
16601660
to be particularly careful about checking internal state. Any exception, other than
16611661
:exc:`AssertionError` or :exc:`SkipTest`, raised by this method will be
@@ -1684,7 +1684,7 @@ Test cases
16841684
Sets up a new event loop to run the test, collecting the result into
16851685
the :class:`TestResult` object passed as *result*. If *result* is
16861686
omitted or ``None``, a temporary result object is created (by calling
1687-
the :meth:`defaultTestResult` method) and used. The result object is
1687+
the :meth:`~TestCase.defaultTestResult` method) and used. The result object is
16881688
returned to :meth:`run`'s caller. At the end of the test all the tasks
16891689
in the event loop are cancelled.
16901690

@@ -1805,7 +1805,7 @@ Grouping tests
18051805
returned by repeated iterations before :meth:`TestSuite.run` must be the
18061806
same for each call iteration. After :meth:`TestSuite.run`, callers should
18071807
not rely on the tests returned by this method unless the caller uses a
1808-
subclass that overrides :meth:`TestSuite._removeTestAtIndex` to preserve
1808+
subclass that overrides :meth:`!TestSuite._removeTestAtIndex` to preserve
18091809
test references.
18101810

18111811
.. versionchanged:: 3.2
@@ -1816,10 +1816,10 @@ Grouping tests
18161816
.. versionchanged:: 3.4
18171817
In earlier versions the :class:`TestSuite` held references to each
18181818
:class:`TestCase` after :meth:`TestSuite.run`. Subclasses can restore
1819-
that behavior by overriding :meth:`TestSuite._removeTestAtIndex`.
1819+
that behavior by overriding :meth:`!TestSuite._removeTestAtIndex`.
18201820

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

18241824

18251825
Loading and running tests
@@ -1853,12 +1853,12 @@ Loading and running tests
18531853
.. method:: loadTestsFromTestCase(testCaseClass)
18541854

18551855
Return a suite of all test cases contained in the :class:`TestCase`\ -derived
1856-
:class:`testCaseClass`.
1856+
:class:`!testCaseClass`.
18571857

18581858
A test case instance is created for each method named by
18591859
:meth:`getTestCaseNames`. By default these are the method names
18601860
beginning with ``test``. If :meth:`getTestCaseNames` returns no
1861-
methods, but the :meth:`runTest` method is implemented, a single test
1861+
methods, but the :meth:`!runTest` method is implemented, a single test
18621862
case is created for that method instead.
18631863

18641864

@@ -1905,13 +1905,13 @@ Loading and running tests
19051905
case class will be picked up as "a test method within a test case class",
19061906
rather than "a callable object".
19071907

1908-
For example, if you have a module :mod:`SampleTests` containing a
1909-
:class:`TestCase`\ -derived class :class:`SampleTestCase` with three test
1910-
methods (:meth:`test_one`, :meth:`test_two`, and :meth:`test_three`), the
1908+
For example, if you have a module :mod:`!SampleTests` containing a
1909+
:class:`TestCase`\ -derived class :class:`!SampleTestCase` with three test
1910+
methods (:meth:`!test_one`, :meth:`!test_two`, and :meth:`!test_three`), the
19111911
specifier ``'SampleTests.SampleTestCase'`` would cause this method to
19121912
return a suite which will run all three test methods. Using the specifier
19131913
``'SampleTests.SampleTestCase.test_two'`` would cause it to return a test
1914-
suite which will run only the :meth:`test_two` test method. The specifier
1914+
suite which will run only the :meth:`!test_two` test method. The specifier
19151915
can refer to modules and packages which have not been imported; they will
19161916
be imported as a side-effect.
19171917

@@ -2058,7 +2058,7 @@ Loading and running tests
20582058
Testing frameworks built on top of :mod:`unittest` may want access to the
20592059
:class:`TestResult` object generated by running a set of tests for reporting
20602060
purposes; a :class:`TestResult` instance is returned by the
2061-
:meth:`TestRunner.run` method for this purpose.
2061+
:meth:`!TestRunner.run` method for this purpose.
20622062

20632063
:class:`TestResult` instances have the following attributes that will be of
20642064
interest when inspecting the results of running a set of tests:
@@ -2144,12 +2144,12 @@ Loading and running tests
21442144

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

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

21552155
The following methods of the :class:`TestResult` class are used to maintain
@@ -2469,9 +2469,9 @@ Class and Module Fixtures
24692469
-------------------------
24702470

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

24762476
Similarly if a test is from a different module from the previous test then
24772477
``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)