New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:
It is documented, that divmod() returns a pair. It is usually used with tuple unpacking: x, y = divmod(a, b) But this doesn't work when one of arguments is a MagicMock. >>> from unittest.mock import * >>> x, y = divmod(MagicMock(), 2) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: not enough values to unpack (expected 2, got 0) I expect that tuple unpacking will work with the result of MagicMock.__divmod__(). There possible following options: 1. Return some constant value, e.g. (1, 0). 2. Return a pair of new MagicMock instances. 3. Define __divmod__ in terms of __floordiv__ and __mod__. This will automatically return a pair of MagicMock instances by default, but setting return values for __floordiv__ and __mod__ will affect the result of __divmod__. What is more preferable? ---------- components: Library (Lib) messages: 325571 nosy: michael.foord, serhiy.storchaka priority: normal severity: normal status: open title: MagicMock.__divmod__ should return a pair type: behavior versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34716> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com