@@ -824,8 +824,9 @@ apply to method calls on the mock object.
824824
825825.. class :: PropertyMock(*args, **kwargs)
826826
827- A mock intended to be used as a property, or other descriptor, on a class.
828- :class: `PropertyMock ` provides :meth: `__get__ ` and :meth: `__set__ ` methods
827+ A mock intended to be used as a :class: `property `, or other
828+ :term: `descriptor `, on a class. :class: `PropertyMock ` provides
829+ :meth: `~object.__get__ ` and :meth: `~object.__set__ ` methods
829830 so you can specify a return value when it is fetched.
830831
831832 Fetching a :class: `PropertyMock ` instance from an object calls the mock, with
@@ -1707,8 +1708,9 @@ Keywords can be used in the :func:`patch.dict` call to set values in the diction
17071708:func: `patch.dict ` can be used with dictionary like objects that aren't actually
17081709dictionaries. At the very minimum they must support item getting, setting,
17091710deleting and either iteration or membership test. This corresponds to the
1710- magic methods :meth: `~object.__getitem__ `, :meth: `__setitem__ `, :meth: `__delitem__ ` and either
1711- :meth: `__iter__ ` or :meth: `__contains__ `.
1711+ magic methods :meth: `~object.__getitem__ `, :meth: `~object.__setitem__ `,
1712+ :meth: `~object.__delitem__ ` and either :meth: `~container.__iter__ ` or
1713+ :meth: `~object.__contains__ `.
17121714
17131715 >>> class Container :
17141716 ... def __init__ (self ):
@@ -2171,7 +2173,7 @@ For example:
21712173 >>> object () in mock
21722174 False
21732175
2174- The two equality methods, :meth: `__eq__ ` and :meth: `__ne__ `, are special.
2176+ The two equality methods, :meth: `! __eq__ ` and :meth: `! __ne__ `, are special.
21752177They do the default equality comparison on identity, using the
21762178:attr: `~Mock.side_effect ` attribute, unless you change their return value to
21772179return something else::
@@ -2521,8 +2523,8 @@ mock_open
25212523 *read_data * is now reset on each call to the *mock *.
25222524
25232525 .. versionchanged :: 3.8
2524- Added :meth: `__iter__ ` to implementation so that iteration (such as in for
2525- loops) correctly consumes *read_data *.
2526+ Added :meth: `~container. __iter__ ` to implementation so that iteration
2527+ (such as in for loops) correctly consumes *read_data *.
25262528
25272529Using :func: `open ` as a context manager is a great way to ensure your file handles
25282530are closed properly and is becoming common::
@@ -2704,7 +2706,7 @@ able to use autospec. On the other hand it is much better to design your
27042706objects so that introspection is safe [# ]_.
27052707
27062708A more serious problem is that it is common for instance attributes to be
2707- created in the :meth: `__init__ ` method and not to exist on the class at all.
2709+ created in the :meth: `~object. __init__ ` method and not to exist on the class at all.
27082710*autospec * can't know about any dynamically created attributes and restricts
27092711the api to visible attributes. ::
27102712
@@ -2745,8 +2747,9 @@ this particular scenario:
27452747 AttributeError: Mock object has no attribute 'a'
27462748
27472749Probably the best way of solving the problem is to add class attributes as
2748- default values for instance members initialised in :meth: `__init__ `. Note that if
2749- you are only setting default attributes in :meth: `__init__ ` then providing them via
2750+ default values for instance members initialised in :meth: `~object.__init__ `.
2751+ Note that if
2752+ you are only setting default attributes in :meth: `!__init__ ` then providing them via
27502753class attributes (shared between instances of course) is faster too. e.g.
27512754
27522755.. code-block :: python
0 commit comments