Repository navigation
Commit a8bd0b1
authored
Honour resetall() arguments for non-callable mocks (#606)
reset_mock() is defined on NonCallableMock, but resetall() narrowed the
kwargs-capable set to (Mock, AsyncMock). NonCallableMagicMock -- what
mocker.create_autospec(cls, instance=True) returns -- is not a Mock
subclass, so return_value= and side_effect= were silently dropped for it.
The guard exists because autospecced functions carry a no-argument
reset_mock closure (issue #237); those are plain functions, so they still
take the else branch. AsyncMock was redundant: it already subclasses Mock.
Co-authored-by: Dylan Pulver <dylanpulver@users.noreply.github.com>1 parent 6559fdf commit a8bd0b1
3 files changed
Lines changed: 19 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | 133 | | |
140 | 134 | | |
141 | 135 | | |
| |||
145 | 139 | | |
146 | 140 | | |
147 | 141 | | |
148 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
149 | 147 | | |
150 | 148 | | |
151 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
227 | 240 | | |
228 | 241 | | |
229 | 242 | | |
| |||
0 commit comments