summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.mock.rst
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-03-11 07:43:25 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-03-11 07:43:25 (GMT)
commita41fb4be5bd6ecb931f53c86f255e7e9d185bbcb (patch)
tree560fe3d427882d25669b8c8b548cedafaf514fb6 /Doc/library/unittest.mock.rst
parent05cd03aa0dd53bdee72ff3a996873341d0e6ba19 (diff)
parentc9cfcf1e6cd946492be949533de906785d690069 (diff)
downloadcpython-a41fb4be5bd6ecb931f53c86f255e7e9d185bbcb.zip
cpython-a41fb4be5bd6ecb931f53c86f255e7e9d185bbcb.tar.gz
cpython-a41fb4be5bd6ecb931f53c86f255e7e9d185bbcb.tar.bz2
#17351: merge with 3.3.
Diffstat (limited to 'Doc/library/unittest.mock.rst')
-rw-r--r--Doc/library/unittest.mock.rst16
1 files changed, 8 insertions, 8 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 1b8f6b4..b71c98e 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -715,7 +715,7 @@ apply to method calls on the mock object.
Fetching a `PropertyMock` instance from an object calls the mock, with
no args. Setting it calls the mock with the value being set.
- >>> class Foo(object):
+ >>> class Foo:
... @property
... def foo(self):
... return 'something'
@@ -1051,7 +1051,7 @@ can set the `return_value` to be anything you want.
To configure return values on methods of *instances* on the patched class
you must do this on the `return_value`. For example:
- >>> class Class(object):
+ >>> class Class:
... def method(self):
... pass
...
@@ -1224,7 +1224,7 @@ deleting and either iteration or membership test. This corresponds to the
magic methods `__getitem__`, `__setitem__`, `__delitem__` and either
`__iter__` or `__contains__`.
- >>> class Container(object):
+ >>> class Container:
... def __init__(self):
... self.values = {}
... def __getitem__(self, name):
@@ -1398,7 +1398,7 @@ inform the patchers of the different prefix by setting `patch.TEST_PREFIX`:
>>> value = 3
>>>
>>> @patch('__main__.value', 'not three')
- ... class Thing(object):
+ ... class Thing:
... def foo_one(self):
... print value
... def foo_two(self):
@@ -2157,7 +2157,7 @@ created in the `__init__` method and not to exist on the class at all.
`autospec` can't know about any dynamically created attributes and restricts
the api to visible attributes.
- >>> class Something(object):
+ >>> class Something:
... def __init__(self):
... self.a = 33
...
@@ -2200,7 +2200,7 @@ class attributes (shared between instances of course) is faster too. e.g.
.. code-block:: python
- class Something(object):
+ class Something:
a = 33
This brings up another issue. It is relatively common to provide a default
@@ -2211,7 +2211,7 @@ spec, and probably indicates a member that will normally of some other type,
`autospec` doesn't use a spec for members that are set to `None`. These will
just be ordinary mocks (well - `MagicMocks`):
- >>> class Something(object):
+ >>> class Something:
... member = None
...
>>> mock = create_autospec(Something)
@@ -2226,7 +2226,7 @@ production class. Both of these require you to use an alternative object as
the spec. Thankfully `patch` supports this - you can simply pass the
alternative object as the `autospec` argument:
- >>> class Something(object):
+ >>> class Something:
... def __init__(self):
... self.a = 33
...