Repository navigation
Commit 60bbe51
committed
bpo-32092: consumes self/cls arguments when patching methods
Currently, when patching methods with autospec, their self / cls
arguments are not consumed, causing call asserts to fail (they
expect an instance / class reference as the first argument).
Example:
from unittest import mock
class Something(object):
def foo(self, a, b, c, d):
pass
patcher = mock.patch.object(Something, 'foo', autospec=True)
patcher.start()
s = Something()
s.foo()1 parent 13f993d commit 60bbe51
3 files changed
Lines changed: 34 additions & 4 deletions
File tree
- Lib/unittest
- test/testmock
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
158 | 162 | | |
159 | 163 | | |
160 | 164 | | |
| |||
1354 | 1358 | | |
1355 | 1359 | | |
1356 | 1360 | | |
| 1361 | + | |
1357 | 1362 | | |
1358 | | - | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
1359 | 1371 | | |
| 1372 | + | |
1360 | 1373 | | |
1361 | | - | |
| 1374 | + | |
| 1375 | + | |
1362 | 1376 | | |
1363 | 1377 | | |
1364 | 1378 | | |
| |||
2252 | 2266 | | |
2253 | 2267 | | |
2254 | 2268 | | |
| 2269 | + | |
| 2270 | + | |
2255 | 2271 | | |
2256 | | - | |
2257 | | - | |
2258 | 2272 | | |
2259 | 2273 | | |
2260 | 2274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
790 | 790 | | |
791 | 791 | | |
792 | 792 | | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
793 | 808 | | |
794 | 809 | | |
795 | 810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments