You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2 #135368
Furthermore the resulting mock doesn't have attributes present on a dataclass instance, like __annotations__, __class__, __dataclass_fields__, __dataclass_params__.
rebase the original PR branch (I think GH hangs onto its HEAD commit on the PR even if it was deleted)
See what happens with the new tests
If they fail, #124429 should probably be reverted for now, andthe old PR plus new tests put on a branch somewhere that a suitably motivated contributor could pick up.
If a fix can be created, then a new PR should go up containing the additional tests we missed first time round along with the commit for the fix.
changed the title [-]Regression with create_autospec and dataclasses in 3.14.0b2[/-][+]unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2[/+]on Jun 11, 2025
Activity
sobolevn commentedon Jun 11, 2025
cc @ncoghlan and @ericvsmith
ericvsmith commentedon Jun 11, 2025
As I said on #124429, I'm not a mock user. That said, the regression does seem problematic. @cjw296 is in CODEOWNERS for mock.
sobolevn commentedon Jun 11, 2025
We might need to revert the change, it seems to be rather hard and the fix is not obvious, at least for me now :(
cjw296 commentedon Jun 11, 2025
@sobolevn - #124429 was your PR so I hope you can dig into this...
I'd probably tackle this as follows:
create_autospec#124429 landed, and add tests forisinstance(mock, Description)and the attributes the OP mentions, verifying the past so we basically confirm the PR is the problemIf they fail, #124429 should probably be reverted for now, andthe old PR plus new tests put on a branch somewhere that a suitably motivated contributor could pick up.
If a fix can be created, then a new PR should go up containing the additional tests we missed first time round along with the commit for the fix.
Hopefully this all makes sense?
sobolevn commentedon Jun 11, 2025
Yes, I will surely work on this. If I can find the solution - I will create a PR with the fix. Otherwise, I propose to revert #124429
cjw296 commentedon Jun 11, 2025
Start with the missing tests first plz, they'll be a valuable artefact whatever the outcome :-)
[-]Regression with create_autospec and dataclasses in 3.14.0b2[/-][+]unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2[/+]pythongh-135368: Fix mocks on dataclass specs with `instance=True`
pythongh-135368: Fix mocks on dataclass specs with `instance=True`
gh-135368: Fix mocks on dataclass specs with `instance=True` (#135421)
pythongh-135368: Fix mocks on dataclass specs with `instance=True` (p…
[3.14] gh-135368: Fix mocks on dataclass specs with `instance=True` (G…
efimov-mikhail commentedon Jun 14, 2025
So, this issue could be closed, right?
cdce8p commentedon Jun 14, 2025
Thanks everyone! Looking forward to the next beta release.
pythongh-135368: Fix mocks on dataclass specs with `instance=True` (p…
pythongh-135368: Fix mocks on dataclass specs with `instance=True` (p…
pythongh-135368: Fix mocks on dataclass specs with `instance=True` (p…
pythongh-135368: Fix mocks on dataclass specs with `instance=True` (p…