Title: unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2 · Issue #135368 · python/cpython · GitHub
Open Graph Title: unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2 · Issue #135368 · python/cpython
X Title: unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2 · Issue #135368 · python/cpython
Description: Bug report Bug description: from dataclasses import dataclass from unittest.mock import create_autospec @dataclass class Description: name: str mock = create_autospec(Description, instance=True) print(isinstance(mock, Description)) # 3.1...
Open Graph Description: Bug report Bug description: from dataclasses import dataclass from unittest.mock import create_autospec @dataclass class Description: name: str mock = create_autospec(Description, instance=True) pr...
X Description: Bug report Bug description: from dataclasses import dataclass from unittest.mock import create_autospec @dataclass class Description: name: str mock = create_autospec(Description, instance=True) pr...
Opengraph URL: https://github.com/python/cpython/issues/135368
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2","articleBody":"# Bug report\n\n### Bug description:\n\n```python\nfrom dataclasses import dataclass\nfrom unittest.mock import create_autospec\n\n@dataclass\nclass Description:\n name: str\n\nmock = create_autospec(Description, instance=True)\nprint(isinstance(mock, Description))\n```\n```py\n# 3.13.3\nTrue\n\n# 3.14.0b2\nFalse\n```\n\nFurthermore the resulting mock doesn't have attributes present on a dataclass instance, like `__annotations__`, `__class__`, `__dataclass_fields__`, `__dataclass_params__`. \n```py\nprint(dir(mock))\nprint(dir(Description(\"Hello World\"))\n```\n\nLikely related to #124429. /CC @sobolevn\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-135421\n* gh-135503\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/cdce8p","@type":"Person","name":"cdce8p"},"datePublished":"2025-06-10T22:21:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/135368/cpython/issues/135368"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:618bed8b-165b-6f15-cf28-976c6fba34ec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFAC:3DCCDD:BD8002:102A93D:6A55B20B |
| html-safe-nonce | e54087d0ff0dde26753944537648e7b2b42dec8e5d7b68301589b5c8a9bd1304 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkFDOjNEQ0NERDpCRDgwMDI6MTAyQTkzRDo2QTU1QjIwQiIsInZpc2l0b3JfaWQiOiI3MjkxMjA2NTY4NzQ5OTM3MTYzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8d1e920fee3b048ebef979937235515a82b0123eb12f36219cc40a133f6402ab |
| hovercard-subject-tag | issue:3134971706 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/135368/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e4d10c51efc83d447549ff19e82ea7bb047f2d125542ec890db1c9baea309a50/python/cpython/issues/135368 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e4d10c51efc83d447549ff19e82ea7bb047f2d125542ec890db1c9baea309a50/python/cpython/issues/135368 |
| og:image:alt | Bug report Bug description: from dataclasses import dataclass from unittest.mock import create_autospec @dataclass class Description: name: str mock = create_autospec(Description, instance=True) pr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cdce8p |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| turbo-cache-control | no-preview |
| 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 | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653fccf1e27344851c0d3de3fa6faa526197f072 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width