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:28e463b1-cece-e2f9-8231-c2ece0400daf |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D986:3B1998:13C2FC6:1AC3976:6A595FD1 |
| html-safe-nonce | 3c93b46e28abe35896a33164acd4be6da04bbd0872287b566e5cbdddf0ff751c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTg2OjNCMTk5ODoxM0MyRkM2OjFBQzM5NzY6NkE1OTVGRDEiLCJ2aXNpdG9yX2lkIjoiODY2NzU3ODg5OTc3MDQ5MDQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7ebc4234e32612463f32efb2d991a7043a8103b7429664f65e84de7b77101392 |
| 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 | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| 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 | f4669eb12cd81bf213b8907a42667725d1583c79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width