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

Created on 2015-03-04 09:27 by zkrynicki, last changed 2015-03-12 18:44 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
issue23581.patch Håkan Lövdahl, 2015-03-07 10:47 review
Messages (5)
msg237176 - (view) Author: Zygmunt Krynicki (zkrynicki) Date: 2015-03-04 09:27
Hi. I'm the upstream of Padme, a mostly transparent proxy library for Python. I was adding support for the new matmul/@ operator when I noticed that MagicMock doens't support it yet.

>>> form unittest.mock import MagicMock
>>> MagicMock() @ 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for @: 'MagicMock' and 'int'

To add support simply add 'matmul' to unittest.mock.numerics.
msg237434 - (view) Author: Håkan Lövdahl (Håkan Lövdahl) Date: 2015-03-07 10:47
Here is a suggestion for a patch. It adds the missing matmul and has a small test for it.
msg237435 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-03-07 10:56
Looks good. I'll tweak the patch and commit it. Thanks Håkan.
msg237972 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-12 18:41
New changeset 8c65480a1e19 by Berker Peksag in branch 'default':
Issue #23581: Add matmul support to MagicMock.
https://hg.python.org/cpython/rev/8c65480a1e19
msg237973 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-03-12 18:44
Thanks for the patch, Håkan. If you want to add tests for other magic methods, please open a new issue.

Thanks for the report, Zygmunt.
History
Date User Action Args
2015-03-12 18:44:21berker.peksagsetstatus: open -> closed
resolution: fixed
messages: + msg237973

stage: commit review -> resolved
2015-03-12 18:41:57python-devsetnosy: + python-dev
messages: + msg237972
2015-03-11 15:09:36serhiy.storchakalinkissue23641 dependencies
2015-03-11 15:09:27serhiy.storchakasetassignee: berker.peksag
stage: patch review -> commit review
2015-03-07 10:56:37berker.peksagsettype: behavior -> enhancement
messages: + msg237435
stage: patch review
2015-03-07 10:47:19Håkan Lövdahlsetfiles: + issue23581.patch

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

keywords: + patch
2015-03-05 14:12:04Saimadhav.Heblikarsetnosy: + Saimadhav.Heblikar
2015-03-04 10:33:00berker.peksagsetnosy: + berker.peksag
2015-03-04 09:27:01zkrynickicreate