@@ -819,8 +819,9 @@ apply to method calls on the mock object.
819819
820820.. class :: PropertyMock(*args, **kwargs)
821821
822- A mock intended to be used as a property, or other descriptor, on a class.
823- :class: `PropertyMock ` provides :meth: `__get__ ` and :meth: `__set__ ` methods
822+ A mock intended to be used as a :class: `property `, or other
823+ :term: `descriptor `, on a class. :class: `PropertyMock ` provides
824+ :meth: `~object.__get__ ` and :meth: `~object.__set__ ` methods
824825 so you can specify a return value when it is fetched.
825826
826827 Fetching a :class: `PropertyMock ` instance from an object calls the mock, with
@@ -1656,8 +1657,9 @@ Keywords can be used in the :func:`patch.dict` call to set values in the diction
16561657:func: `patch.dict ` can be used with dictionary like objects that aren't actually
16571658dictionaries. At the very minimum they must support item getting, setting,
16581659deleting and either iteration or membership test. This corresponds to the
1659- magic methods :meth: `~object.__getitem__ `, :meth: `__setitem__ `, :meth: `__delitem__ ` and either
1660- :meth: `__iter__ ` or :meth: `__contains__ `.
1660+ magic methods :meth: `~object.__getitem__ `, :meth: `~object.__setitem__ `,
1661+ :meth: `~object.__delitem__ ` and either :meth: `~container.__iter__ ` or
1662+ :meth: `~object.__contains__ `.
16611663
16621664 >>> class Container :
16631665 ... def __init__ (self ):
@@ -2120,7 +2122,7 @@ For example:
21202122 >>> object () in mock
21212123 False
21222124
2123- The two equality methods, :meth: `__eq__ ` and :meth: `__ne__ `, are special.
2125+ The two equality methods, :meth: `! __eq__ ` and :meth: `! __ne__ `, are special.
21242126They do the default equality comparison on identity, using the
21252127:attr: `~Mock.side_effect ` attribute, unless you change their return value to
21262128return something else::
@@ -2470,8 +2472,8 @@ mock_open
24702472 *read_data * is now reset on each call to the *mock *.
24712473
24722474 .. versionchanged :: 3.8
2473- Added :meth: `__iter__ ` to implementation so that iteration (such as in for
2474- loops) correctly consumes *read_data *.
2475+ Added :meth: `~container. __iter__ ` to implementation so that iteration
2476+ (such as in for loops) correctly consumes *read_data *.
24752477
24762478Using :func: `open ` as a context manager is a great way to ensure your file handles
24772479are closed properly and is becoming common::
@@ -2653,7 +2655,7 @@ able to use autospec. On the other hand it is much better to design your
26532655objects so that introspection is safe [# ]_.
26542656
26552657A more serious problem is that it is common for instance attributes to be
2656- created in the :meth: `__init__ ` method and not to exist on the class at all.
2658+ created in the :meth: `~object. __init__ ` method and not to exist on the class at all.
26572659*autospec * can't know about any dynamically created attributes and restricts
26582660the api to visible attributes. ::
26592661
@@ -2694,8 +2696,9 @@ this particular scenario:
26942696 AttributeError: Mock object has no attribute 'a'
26952697
26962698Probably the best way of solving the problem is to add class attributes as
2697- default values for instance members initialised in :meth: `__init__ `. Note that if
2698- you are only setting default attributes in :meth: `__init__ ` then providing them via
2699+ default values for instance members initialised in :meth: `~object.__init__ `.
2700+ Note that if
2701+ you are only setting default attributes in :meth: `!__init__ ` then providing them via
26992702class attributes (shared between instances of course) is faster too. e.g.
27002703
27012704.. code-block :: python
0 commit comments