[issue25597] unittest.mock does not wrap dunder methods (__getitem__ etc)

anthony shaw report at bugs.python.org
Mon May 6 15:29:13 EDT 2019


anthony shaw <anthonyshaw at apache.org> added the comment:

The assertions in the attached test still fail on master (3.8a3), so this still applies. 

Michael, are you able to look at this, the code hasn't changed since the original PEP417 implementation, which doesn't specify if this behaviour should be supported.

The documentation does not specify that this is supported also, so i suspect this is an enhancement request.

        elif result is None:
            wraps = None
            if self._mock_wraps is not None:
                # XXXX should we get the attribute without triggering code
                # execution?
                wraps = getattr(self._mock_wraps, name)

            result = self._get_child_mock(
                parent=self, name=name, wraps=wraps, _new_name=name,
                _new_parent=self
            )

----------
nosy: +anthonypjshaw

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue25597>
_______________________________________


More information about the Python-bugs-list mailing list