@@ -820,8 +820,9 @@ apply to method calls on the mock object.
820820
821821.. class :: PropertyMock(*args, **kwargs)
822822
823- A mock intended to be used as a property, or other descriptor, on a class.
824- :class: `PropertyMock ` provides :meth: `__get__ ` and :meth: `__set__ ` methods
823+ A mock intended to be used as a :class: `property `, or other
824+ :term: `descriptor `, on a class. :class: `PropertyMock ` provides
825+ :meth: `~object.__get__ ` and :meth: `~object.__set__ ` methods
825826 so you can specify a return value when it is fetched.
826827
827828 Fetching a :class: `PropertyMock ` instance from an object calls the mock, with
@@ -1658,8 +1659,9 @@ Keywords can be used in the :func:`patch.dict` call to set values in the diction
16581659:func: `patch.dict ` can be used with dictionary like objects that aren't actually
16591660dictionaries. At the very minimum they must support item getting, setting,
16601661deleting and either iteration or membership test. This corresponds to the
1661- magic methods :meth: `~object.__getitem__ `, :meth: `__setitem__ `, :meth: `__delitem__ ` and either
1662- :meth: `__iter__ ` or :meth: `__contains__ `.
1662+ magic methods :meth: `~object.__getitem__ `, :meth: `~object.__setitem__ `,
1663+ :meth: `~object.__delitem__ ` and either :meth: `~container.__iter__ ` or
1664+ :meth: `~object.__contains__ `.
16631665
16641666 >>> class Container :
16651667 ... def __init__ (self ):
@@ -2122,7 +2124,7 @@ For example:
21222124 >>> object () in mock
21232125 False
21242126
2125- The two equality methods, :meth: `__eq__ ` and :meth: `__ne__ `, are special.
2127+ The two equality methods, :meth: `! __eq__ ` and :meth: `! __ne__ `, are special.
21262128They do the default equality comparison on identity, using the
21272129:attr: `~Mock.side_effect ` attribute, unless you change their return value to
21282130return something else::
@@ -2472,8 +2474,8 @@ mock_open
24722474 *read_data * is now reset on each call to the *mock *.
24732475
24742476 .. versionchanged :: 3.8
2475- Added :meth: `__iter__ ` to implementation so that iteration (such as in for
2476- loops) correctly consumes *read_data *.
2477+ Added :meth: `~container. __iter__ ` to implementation so that iteration
2478+ (such as in for loops) correctly consumes *read_data *.
24772479
24782480Using :func: `open ` as a context manager is a great way to ensure your file handles
24792481are closed properly and is becoming common::
@@ -2655,7 +2657,7 @@ able to use autospec. On the other hand it is much better to design your
26552657objects so that introspection is safe [# ]_.
26562658
26572659A more serious problem is that it is common for instance attributes to be
2658- created in the :meth: `__init__ ` method and not to exist on the class at all.
2660+ created in the :meth: `~object. __init__ ` method and not to exist on the class at all.
26592661*autospec * can't know about any dynamically created attributes and restricts
26602662the api to visible attributes. ::
26612663
@@ -2696,8 +2698,9 @@ this particular scenario:
26962698 AttributeError: Mock object has no attribute 'a'
26972699
26982700Probably the best way of solving the problem is to add class attributes as
2699- default values for instance members initialised in :meth: `__init__ `. Note that if
2700- you are only setting default attributes in :meth: `__init__ ` then providing them via
2701+ default values for instance members initialised in :meth: `~object.__init__ `.
2702+ Note that if
2703+ you are only setting default attributes in :meth: `!__init__ ` then providing them via
27012704class attributes (shared between instances of course) is faster too. e.g.
27022705
27032706.. code-block :: python
0 commit comments