classification
Title: unittest.mock.MagicMock doesn't support __rdivmod__
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Håkan Lövdahl, berker.peksag, michael.foord, python-dev, rbcollins, zkrynicki
Priority: normal Keywords: patch

Created on 2015-03-03 08:36 by zkrynicki, last changed 2015-03-15 00:02 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
issue23568.patch Håkan Lövdahl, 2015-03-07 12:04 patch and test review
Messages (4)
msg237112 - (view) Author: Zygmunt Krynicki (zkrynicki) Date: 2015-03-03 08:36
Hey.

I'm the upstream developer of padme https://github.com/zyga/padme -- the mostly transparent proxy class for Python. While working on unit tests for proxying numeric methods I realized that there are a few bugs in the mock library.

The bug I'd like to report now is that __rdivmod__ cannot be mocked by MagicMock. This seems to be caused by the fact that it is listed as magic but not as numeric (for which right-hand-side variants are created).

Note that it cannot be simply added to numeric as it doesn't have the augmented assignment variant (there is no __idivmod__).

The bug is present in all versions of Python that come with unittest.mock (3.3, 3.4 and 3.5) and it is also present in the upstream/standalone version of mock
msg237441 - (view) Author: Håkan Lövdahl (Håkan Lövdahl) Date: 2015-03-07 12:04
I wrote a small patch and a test for it. Tested it on Python 3.5 and it worked.
msg238111 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-14 23:57
New changeset 35a780a9a3b4 by Berker Peksag in branch '3.4':
Issue #23568: Add rdivmod support to MagicMock() objects.
https://hg.python.org/cpython/rev/35a780a9a3b4

New changeset 90f08e7fbdc3 by Berker Peksag in branch 'default':
Issue #23568: Add rdivmod support to MagicMock() objects.
https://hg.python.org/cpython/rev/90f08e7fbdc3
msg238112 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-03-15 00:02
Thanks to both of you for the report and the patch.
History
Date User Action Args
2015-03-15 00:02:16berker.peksagsetstatus: open -> closed
versions: + Python 3.4, Python 3.5, - Python 3.3
messages: + msg238112

resolution: fixed
stage: resolved
2015-03-14 23:57:44python-devsetnosy: + python-dev
messages: + msg238111
2015-03-07 12:04:08Håkan Lövdahlsetfiles: + issue23568.patch

nosy: + Håkan Lövdahl
messages: + msg237441

keywords: + patch
2015-03-04 02:57:01berker.peksagsetnosy: + berker.peksag
2015-03-03 22:42:18ned.deilysetnosy: + rbcollins, michael.foord
2015-03-03 08:42:49zkrynickisettype: behavior
versions: + Python 3.3, - Python 3.4, Python 3.5
2015-03-03 08:36:32zkrynickisettitle: unittest.mock.MagicMock doesn't support __rdivmod__t -> unittest.mock.MagicMock doesn't support __rdivmod__
2015-03-03 08:36:25zkrynickicreate