Skip to content

Commit bf59464

Browse files
committed
Proof-read docs
1 parent e56a98f commit bf59464

3 files changed

Lines changed: 22 additions & 20 deletions

File tree

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Release 2.0.0 (March 10, 2026)
3232
from mockito import InOrder
3333
in_order = InOrder(cat) # <== pass multiple objects for cross-mock verification!
3434
in_order.verify(cat).meow()
35-
inorder.verify(cat).purr()
35+
in_order.verify(cat).purr()
3636

3737
- The legacy in-order verification mode (``inorder.verify(...)``)
3838
is deprecated in favor of ``InOrder(...)``.

docs/any-and-ellipses.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Any markers and ellipses
22
=========================
33

4-
Let's look at how the Ellipsis marker (`...`) works in mockito.
4+
Let's look at how the Ellipsis marker (``...``) works in mockito.
55

66
Assume:
77

@@ -17,7 +17,7 @@ Given
1717

1818
when(C).function(...)
1919

20-
The sole `...` denotes a "whatever" matcher.
20+
The sole ``...`` denotes a "whatever" matcher.
2121

2222
These are allowed:
2323

@@ -39,7 +39,7 @@ When configured as:
3939

4040
when(C).function(2, ...)
4141

42-
The trailing `...` denotes a rest matcher. We match up to the `2`; the rest is accepted.
42+
The trailing ``...`` denotes a rest matcher. We match up to the `2`; the rest is accepted.
4343

4444
::
4545

@@ -67,10 +67,10 @@ Allows:
6767
function(1, 2, three=3)
6868

6969

70-
Fixed-position ellipsis (`...`) as `any`
70+
Relation to `any`
7171
----------------------------------------
7272

73-
`...` can also be used in a fixed position as an ad-hoc `any` matcher.
73+
``...`` can also be used in a fixed position as an ad-hoc `any` matcher.
7474

7575
Assume:
7676

@@ -149,12 +149,13 @@ With that configuration, naturally follows::
149149
Relation to `*args`
150150
-------------------
151151

152-
If you want to match `*args` (multiple arguments), use `args`:
152+
If you want to match `*args` (multiple arguments), use ``args``:
153153

154154
::
155155

156156
def sum(*args): ...
157157

158+
from mockito import args
158159
when(C).sum(1, 2, *args)
159160

160161
Allows:
@@ -164,14 +165,15 @@ Allows:
164165
sum(1, 2, 3)
165166
sum(1, 2, 3, 4)
166167

167-
That is similar to plain trailing `...`, but `args` also composes with keyword arguments.
168+
That is similar to plain trailing ``...``, but ``args`` also composes with keyword arguments.
168169

169170
Assume:
170171

171172
::
172173

173174
def sum(*args, init=0): ...
174175

176+
from mockito import args
175177
when(C).sum(1, 2, *args, init=5)
176178

177179
Allows:
@@ -187,7 +189,7 @@ But:
187189

188190
when(C).sum(1, 2, ..., init=5)
189191

190-
uses fixed-position `...` (one value), so it allows:
192+
uses fixed-position ``...`` (one value), so it allows:
191193

192194
::
193195

@@ -210,10 +212,11 @@ Ideally we could write:
210212

211213
when(C).fetch("https://example.com/", retry=..., ...)
212214

213-
but that's not valid Python syntax. Use `kwargs` instead:
215+
but that's not valid Python syntax. Use ``kwargs`` instead:
214216

215217
::
216218

219+
from mockito import kwargs
217220
when(C).fetch("https://example.com/", retry=..., **kwargs)
218221

219222
Allows:
@@ -226,6 +229,7 @@ And:
226229

227230
::
228231

232+
from mockito import kwargs
229233
when(C).fetch(..., retry=2, **kwargs)
230234

231235
Allows:
@@ -236,5 +240,5 @@ Allows:
236240
fetch("https://foobar.com/", retry=2)
237241
fetch("https://foobar.com/", retry=2, headers={})
238242

239-
Use `kwargs` as the rest marker where `...` is not syntactically available
243+
Use ``kwargs`` as the rest marker where ``...`` is not syntactically available
240244
because specific keyword arguments are already configured.

docs/mock-shorthands.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,19 @@ To build up a complete `aiohttp` example::
5151

5252
you also need to define the context/with handlers::
5353

54-
resp = mock({
55-
"__aenter__": ...,
56-
"async text": lambda: "Fake!"
57-
})
58-
5954
session = mock({
55+
"async get": lambda: resp, # <== install async method with *args, **kwargs
56+
# equivalent to when(session).get(...).thenReturn(resp)
57+
})
58+
resp = mock({
6059
# since __aenter__ is async by protocol "async __aenter__" is not needed (but allowed)
6160
"__aenter__": ..., # <== ... denotes to install a standard return value of self
6261
# it always installs a standard __aexit__ returning None or False
6362
# if not provided by the user
64-
65-
"async get": lambda: resp, # <== install async method with *args, **kwargs
66-
# equivalent to when(session).get(...).thenReturn(resp)
63+
"async text": lambda: "Fake!"
6764
})
6865

66+
6967
.. note::
7068

7169
``__aenter__``, ``__aexit__``, ``__anext__`` are async by definition,
@@ -81,7 +79,7 @@ For ``__aiter__``, we have a special shortcode::
8179
...
8280

8381

84-
You can also just mark a function async::
82+
You can also just mark a function async using the Ellipsis::
8583

8684
session = mock({
8785
"__aenter__": ...,

0 commit comments

Comments
 (0)