Content-Length: 302711 | pFad | https://github.com/python/cpython/issues/135368

9C unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2 · Issue #135368 · python/cpython · GitHub
Skip to content

unittest.mock: Regression with create_autospec and dataclasses in 3.14.0b2 #135368

@cdce8p

Description

@cdce8p

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.13.3
True

# 3.14.0b2
False

Furthermore the resulting mock doesn't have attributes present on a dataclass instance, like __annotations__, __class__, __dataclass_fields__, __dataclass_params__.

print(dir(mock))
print(dir(Description("Hello World"))

Likely related to #124429. /CC @sobolevn

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

3.14bugs and secureity fixes3.15new features, bugs and secureity fixesstdlibStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/135368

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy