Title: bpo-32153: Add unit test for create_autospec with partial function returned in getattr by tirkarthi · Pull Request #10398 · python/cpython · GitHub
Open Graph Title: bpo-32153: Add unit test for create_autospec with partial function returned in getattr by tirkarthi · Pull Request #10398 · python/cpython
X Title: bpo-32153: Add unit test for create_autospec with partial function returned in getattr by tirkarthi · Pull Request #10398 · python/cpython
Description: This adds an unit test for https://bugs.python.org/issue32153 which was out dated and fixed by https://bugs.python.org/issue28919 . During create_autospec the function attributes are copied and when getattr returns a partial function then it doesn't contain __name__ causing AttributeError . This was fixed in 3.7 suppressing AttributeError but was not backported thus this test can be applied only on 3.7 and master. Fails on 3.6 branch cpython git:(25bd107399) ./python.exe Python 3.6.7+ (remotes/upstream/3.6:25bd107399, Nov 8 2018, 00:50:43) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> ^D cpython git:(25bd107399) ./python.exe -m unittest -v unittest.test.testmock.testhelpers.SpecSignatureTest.test_autospec_getattr_partial_function test_autospec_getattr_partial_function (unittest.test.testmock.testhelpers.SpecSignatureTest) ... ERROR ====================================================================== ERROR: test_autospec_getattr_partial_function (unittest.test.testmock.testhelpers.SpecSignatureTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/test/testmock/testhelpers.py", line 884, in test_autospec_getattr_partial_function autospec = create_autospec(proxy) File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", line 2182, in create_autospec _check_signature(spec, mock, is_type, instance) File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", line 102, in _check_signature _copy_func_details(func, checksig) File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", line 107, in _copy_func_details funcopy.__name__ = func.__name__ AttributeError: 'functools.partial' object has no attribute '__name__' ---------------------------------------------------------------------- Ran 1 test in 0.007s FAILED (errors=1) Passes on master cpython git:(bpo32153) ./python.exe Python 3.8.0a0 (heads/bpo32153:3e9cd8d982, Nov 8 2018, 00:53:46) [Clang 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> ^D cpython git:(bpo32153) ./python.exe -m unittest -v unittest.test.testmock.testhelpers.SpecSignatureTest.test_autospec_getattr_partial_function test_autospec_getattr_partial_function (unittest.test.testmock.testhelpers.SpecSignatureTest) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.005s OK https://bugs.python.org/issue32513
Open Graph Description: This adds an unit test for https://bugs.python.org/issue32153 which was out dated and fixed by https://bugs.python.org/issue28919 . During create_autospec the function attributes are copied and whe...
X Description: This adds an unit test for https://bugs.python.org/issue32153 which was out dated and fixed by https://bugs.python.org/issue28919 . During create_autospec the function attributes are copied and whe...
Opengraph URL: https://github.com/python/cpython/pull/10398
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:ee2de88f-cdf2-bc97-f41a-4b666490f86a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CCB4:4F057:126975D:190640D:6A4C738A |
| html-safe-nonce | 45296ad35796218d0cf172b747e2e180e8b71fa4498b08ef29e31f661db205c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0I0OjRGMDU3OjEyNjk3NUQ6MTkwNjQwRDo2QTRDNzM4QSIsInZpc2l0b3JfaWQiOiI0NjU3MTA4Mjg0MzY4MjUzODM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ccefc889e06f3a0bd0c24fe2f475022be06d0bae0c25799e30976c4d1b474a7c |
| hovercard-subject-tag | pull_request:229143368 |
| 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/10398/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 | This adds an unit test for https://bugs.python.org/issue32153 which was out dated and fixed by https://bugs.python.org/issue28919 . During create_autospec the function attributes are copied and whe... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 14099438da5379150f15a2892474c7c7e6c0e55e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width