Title: gh-76273: Fix autospec mocking of instance and class methods by stephenfin · Pull Request #146526 · python/cpython · GitHub
Open Graph Title: gh-76273: Fix autospec mocking of instance and class methods by stephenfin · Pull Request #146526 · python/cpython
X Title: gh-76273: Fix autospec mocking of instance and class methods by stephenfin · Pull Request #146526 · python/cpython
Description: Currently, when patching instance / class 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 with mock.patch.object(Something, 'foo', autospec=True): s = Something() s.foo() Fix this by skipping the first argument when presented with a method. Based on #4476 with the changes to the Mock signature stripped out and left for a separate, follow-up PR. Issue: gh-76273
Open Graph Description: Currently, when patching instance / class methods with autospec, their self / cls arguments are not consumed, causing call asserts to fail (they expect an instance / class reference as the first ar...
X Description: Currently, when patching instance / class methods with autospec, their self / cls arguments are not consumed, causing call asserts to fail (they expect an instance / class reference as the first ar...
Opengraph URL: https://github.com/python/cpython/pull/146526
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:1d12f1f5-d556-2a7d-6872-514311a5726f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DD8A:1255E3:17629AC:21A10A1:6A58BC63 |
| html-safe-nonce | ff7d4d7738c26650dae3b5b9dc043d0467eff74ddf113061dcddf6eb3e75a6f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDhBOjEyNTVFMzoxNzYyOUFDOjIxQTEwQTE6NkE1OEJDNjMiLCJ2aXNpdG9yX2lkIjoiNTMzNDc3NjQ3NDk2NDExNDUzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bd1212a79604d656582f5886ca6c6fe4b3cfcab3db300ef01326fed89d86b61e |
| hovercard-subject-tag | pull_request:3457760464 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/146526/files |
| twitter:image | https://avatars.githubusercontent.com/u/1690835?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1690835?s=400&v=4 |
| og:image:alt | Currently, when patching instance / class methods with autospec, their self / cls arguments are not consumed, causing call asserts to fail (they expect an instance / class reference as the first ar... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width