[issue39578] MagicMock specialisation instance can no longer be passed to new MagicMock instance

Elena Oat report at bugs.python.org
Mon Feb 10 19:03:09 EST 2020


Elena Oat <oat.elena at gmail.com> added the comment:

Here's the example I ran, that indeed fails in Python 3.8 and Python 3.9 (with different errors) and works in Python 3.7. 

from unittest.mock import MagicMock


class CustomMock(MagicMock):
    def __init__(self):
        super().__init__(__something__='something')


mock = CustomMock()
MagicMock(mock)


In Python 3.8 the error is TypeError: __init__() got an unexpected keyword argument '_new_parent'. 

In Python 3.9 the error is TypeError: __init__() got an unexpected keyword argument 'name'.

----------

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


More information about the Python-bugs-list mailing list