Title: bpo-37251: MagicMock with function spec used as a spec in mock.patch should return a MagicMock by tirkarthi · Pull Request #14117 · python/cpython · GitHub
Open Graph Title: bpo-37251: MagicMock with function spec used as a spec in mock.patch should return a MagicMock by tirkarthi · Pull Request #14117 · python/cpython
X Title: bpo-37251: MagicMock with function spec used as a spec in mock.patch should return a MagicMock by tirkarthi · Pull Request #14117 · python/cpython
Description: MagicMock with a function spec will have __code__ object. When it is used a spec to mock.patch then __code__ object which is a MagicMock is used to detect if it's a coroutine. MagicMock.__code__ & 128 returns another MagicMock which is evaluated to True and returned as a coroutine incorrectly. Hence check __code__ to be a CodeType to make sure MagicMock with __code__ is not detected as coroutine. https://bugs.python.org/issue37251
Open Graph Description: MagicMock with a function spec will have __code__ object. When it is used a spec to mock.patch then __code__ object which is a MagicMock is used to detect if it's a coroutine. MagicMock.__code_...
X Description: MagicMock with a function spec will have __code__ object. When it is used a spec to mock.patch then __code__ object which is a MagicMock is used to detect if it's a coroutine. MagicMock.__c...
Opengraph URL: https://github.com/python/cpython/pull/14117
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e10e9bf6-9d8f-ff0b-9f2c-da9dbdade215 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AFFE:2BB83B:B3B7DA:F46441:6A5557C4 |
| html-safe-nonce | 6a6aae47c8e524e923ba82d3dda3277df6c28020b9e838aee024513097544c0f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkZFOjJCQjgzQjpCM0I3REE6RjQ2NDQxOjZBNTU1N0M0IiwidmlzaXRvcl9pZCI6Ijk4NTAzOTIyNzcyNDMyMjc1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7cc02a7afc8207480a6ab35dcffdde7acd3bb879879bde0890e7228c3c9e3d01 |
| hovercard-subject-tag | pull_request:288567521 |
| 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/14117/files |
| twitter:image | https://avatars.githubusercontent.com/u/3972343?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/3972343?s=400&v=4 |
| og:image:alt | MagicMock with a function spec will have __code__ object. When it is used a spec to mock.patch then __code__ object which is a MagicMock is used to detect if it's a coroutine. MagicMock.__code_... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 73595e82546ca2415571a2031890ab16ecb3001a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width