It would also be good to try and reproduce it with dataclasses, since they have a lot of the same magic. If it failed with dataclasses then we could look at the interaction between mock and dataclasses more easily than if it requires attrs.
I have updated the title of the issues since it may not be an attrs only problem. @AA-Turner@ericvsmith, thank you.
A similar example with dataclasses below.
from dataclasses import dataclass
from unittest.mock import create_autospec
@dataclass
class DummyClass:
a: int
b: int
dummy_class = create_autospec(DummyClass)
dummy_class.a
636 elif self._mock_methods is not None:
637 if name not in self._mock_methods or name in _all_magics:
--> 638 raise AttributeError("Mock object has no attribute %r" % name)
639 elif _is_magic(name):
640 raise AttributeError(name)
AttributeError: Mock object has no attribute 'a'
noklam
changed the title
unittest mock missed attrs class when slots=False?
unittest mock miss attributes with AttributeError with dataclasses and attrs class when slots=False?
May 25, 2022
Bug report
A clear and concise description of what the bug is.

Include a minimal, reproducible example (https://stackoverflow.com/help/minimal-reproducible-example), if possible.
Your environment
The text was updated successfully, but these errors were encountered: