Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb13438

Browse files
committed
Closes #17109: fix heading levels in mock doc.
1 parent 09aa752 commit fb13438

1 file changed

Lines changed: 22 additions & 23 deletions

File tree

Doc/library/unittest.mock.rst

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ method:
926926
927927
928928
The patchers
929-
============
929+
------------
930930

931931
The patch decorators are used for patching objects only within the scope of
932932
the function they decorate. They automatically handle the unpatching for you,
@@ -935,7 +935,7 @@ statements or as class decorators.
935935

936936

937937
patch
938-
-----
938+
~~~~~
939939

940940
.. note::
941941

@@ -1108,7 +1108,7 @@ into a `patch` call using `**`:
11081108

11091109

11101110
patch.object
1111-
------------
1111+
~~~~~~~~~~~~
11121112

11131113
.. function:: patch.object(target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs)
11141114

@@ -1144,7 +1144,7 @@ meaning as they do for `patch`.
11441144

11451145

11461146
patch.dict
1147-
----------
1147+
~~~~~~~~~~
11481148

11491149
.. function:: patch.dict(in_dict, values=(), clear=False, **kwargs)
11501150

@@ -1227,7 +1227,7 @@ magic methods `__getitem__`, `__setitem__`, `__delitem__` and either
12271227

12281228

12291229
patch.multiple
1230-
--------------
1230+
~~~~~~~~~~~~~~
12311231

12321232
.. function:: patch.multiple(target, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs)
12331233

@@ -1291,7 +1291,7 @@ context manger is a dictionary where created mocks are keyed by name:
12911291
.. _start-and-stop:
12921292

12931293
patch methods: start and stop
1294-
-----------------------------
1294+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12951295

12961296
All the patchers have `start` and `stop` methods. These make it simpler to do
12971297
patching in `setUp` methods or where you want to do multiple patches without
@@ -1364,7 +1364,7 @@ It is also possible to stop all patches which have been started by using
13641364

13651365

13661366
TEST_PREFIX
1367-
-----------
1367+
~~~~~~~~~~~
13681368

13691369
All of the patchers can be used as class decorators. When used in this way
13701370
they wrap every test method on the class. The patchers recognise methods that
@@ -1394,7 +1394,7 @@ inform the patchers of the different prefix by setting `patch.TEST_PREFIX`:
13941394

13951395

13961396
Nesting Patch Decorators
1397-
------------------------
1397+
~~~~~~~~~~~~~~~~~~~~~~~~
13981398

13991399
If you want to perform multiple patches then you can simply stack up the
14001400
decorators.
@@ -1423,7 +1423,7 @@ passed into your test function matches this order.
14231423
.. _where-to-patch:
14241424

14251425
Where to patch
1426-
--------------
1426+
~~~~~~~~~~~~~~
14271427

14281428
`patch` works by (temporarily) changing the object that a *name* points to with
14291429
another one. There can be many names pointing to any individual object, so
@@ -1465,7 +1465,7 @@ being looked up on the a module and so we have to patch `a.SomeClass` instead::
14651465

14661466

14671467
Patching Descriptors and Proxy Objects
1468-
--------------------------------------
1468+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14691469

14701470
Both patch_ and patch.object_ correctly patch and restore descriptors: class
14711471
methods, static methods and properties. You should patch these on the *class*
@@ -1475,12 +1475,12 @@ that proxy attribute access, like the `django setttings object
14751475

14761476

14771477
MagicMock and magic method support
1478-
==================================
1478+
----------------------------------
14791479

14801480
.. _magic-methods:
14811481

14821482
Mocking Magic Methods
1483-
---------------------
1483+
~~~~~~~~~~~~~~~~~~~~~
14841484

14851485
:class:`Mock` supports mocking the Python protocol methods, also known as
14861486
"magic methods". This allows mock objects to replace containers or other
@@ -1566,7 +1566,7 @@ by mock, can't be set dynamically, or can cause problems:
15661566

15671567

15681568
Magic Mock
1569-
----------
1569+
~~~~~~~~~~
15701570

15711571
There are two `MagicMock` variants: `MagicMock` and `NonCallableMagicMock`.
15721572

@@ -1695,10 +1695,10 @@ Magic methods that are supported but not setup by default in ``MagicMock`` are:
16951695
16961696
16971697
Helpers
1698-
=======
1698+
-------
16991699

17001700
sentinel
1701-
--------
1701+
~~~~~~~~
17021702

17031703
.. data:: sentinel
17041704

@@ -1726,7 +1726,7 @@ In this example we monkey patch `method` to return `sentinel.some_object`:
17261726

17271727

17281728
DEFAULT
1729-
-------
1729+
~~~~~~~
17301730

17311731

17321732
.. data:: DEFAULT
@@ -1736,9 +1736,8 @@ DEFAULT
17361736
functions to indicate that the normal return value should be used.
17371737

17381738

1739-
17401739
call
1741-
----
1740+
~~~~
17421741

17431742
.. function:: call(*args, **kwargs)
17441743

@@ -1827,7 +1826,7 @@ arguments are a dictionary:
18271826

18281827

18291828
create_autospec
1830-
---------------
1829+
~~~~~~~~~~~~~~~
18311830

18321831
.. function:: create_autospec(spec, spec_set=False, instance=False, **kwargs)
18331832

@@ -1854,7 +1853,7 @@ See :ref:`auto-speccing` for examples of how to use auto-speccing with
18541853

18551854

18561855
ANY
1857-
---
1856+
~~~
18581857

18591858
.. data:: ANY
18601859

@@ -1885,7 +1884,7 @@ passed in.
18851884

18861885

18871886
FILTER_DIR
1888-
----------
1887+
~~~~~~~~~~
18891888

18901889
.. data:: FILTER_DIR
18911890

@@ -1940,7 +1939,7 @@ Alternatively you can just use `vars(my_mock)` (instance members) and
19401939

19411940

19421941
mock_open
1943-
---------
1942+
~~~~~~~~~
19441943

19451944
.. function:: mock_open(mock=None, read_data=None)
19461945

@@ -1994,7 +1993,7 @@ And for reading files:
19941993
.. _auto-speccing:
19951994

19961995
Autospeccing
1997-
------------
1996+
~~~~~~~~~~~~
19981997

19991998
Autospeccing is based on the existing `spec` feature of mock. It limits the
20001999
api of mocks to the api of an original object (the spec), but it is recursive

0 commit comments

Comments
 (0)