summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.mock-examples.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-examples.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-examples.rst')
-rw-r--r--Doc/library/unittest.mock-examples.rst16
1 files changed, 8 insertions, 8 deletions
diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst
index cbdba1d..f32a282 100644
--- a/Doc/library/unittest.mock-examples.rst
+++ b/Doc/library/unittest.mock-examples.rst
@@ -45,7 +45,7 @@ the correct arguments.
This example tests that calling `ProductionClass().method` results in a call to
the `something` method:
- >>> class ProductionClass(object):
+ >>> class ProductionClass:
... def method(self):
... self.something(1, 2, 3)
... def something(self, a, b, c):
@@ -69,7 +69,7 @@ in the correct way.
The simple `ProductionClass` below has a `closer` method. If it is called with
an object then it calls `close` on it.
- >>> class ProductionClass(object):
+ >>> class ProductionClass:
... def closer(self, something):
... something.close()
...
@@ -412,7 +412,7 @@ ends:
Where you use `patch` to create a mock for you, you can get a reference to the
mock using the "as" form of the with statement:
- >>> class ProductionClass(object):
+ >>> class ProductionClass:
... def method(self):
... pass
...
@@ -460,7 +460,7 @@ testable way in the first place...
So, suppose we have some code that looks a little bit like this:
- >>> class Something(object):
+ >>> class Something:
... def __init__(self):
... self.backend = BackendProvider()
... def method(self):
@@ -568,7 +568,7 @@ mock this using a `MagicMock`.
Here's an example class with an "iter" method implemented as a generator:
- >>> class Foo(object):
+ >>> class Foo:
... def iter(self):
... for i in [1, 2, 3]:
... yield i
@@ -678,7 +678,7 @@ function will be turned into a bound method if it is fetched from an instance.
It will have `self` passed in as the first argument, which is exactly what I
wanted:
- >>> class Foo(object):
+ >>> class Foo:
... def foo(self):
... pass
...
@@ -1197,7 +1197,7 @@ for us.
You can see in this example how a 'standard' call to `assert_called_with` isn't
sufficient:
- >>> class Foo(object):
+ >>> class Foo:
... def __init__(self, a, b):
... self.a, self.b = a, b
...
@@ -1224,7 +1224,7 @@ A comparison function for our `Foo` class might look something like this:
And a matcher object that can use comparison functions like this for its
equality operation would look something like this:
- >>> class Matcher(object):
+ >>> class Matcher:
... def __init__(self, compare, some_obj):
... self.compare = compare
... self.some_obj = some_obj