How can one mock the dictionary unpacking operator (**
)?
Expected pseudo Python code:
from unittest import mock
a = mock.MagicMock()
a.__unpack__.return_value = {'foo': 'bar'} # this is pseudo code
b = {**a}
print(b)
>>> {'foo': 'bar'}
Can this be done? I've found this question that suggests overloading __getitem__
is the way to go, but that doesn't seem to work for mocking.
Aucun commentaire:
Enregistrer un commentaire