Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest.mock.MagicMock doesn't support matmul (@) operator #67769

Closed
zkrynicki mannequin opened this issue Mar 4, 2015 · 5 comments
Closed

unittest.mock.MagicMock doesn't support matmul (@) operator #67769

zkrynicki mannequin opened this issue Mar 4, 2015 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@zkrynicki
Copy link
Mannequin

zkrynicki mannequin commented Mar 4, 2015

BPO 23581
Nosy @berkerpeksag
Files
  • issue23581.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/berkerpeksag'
    closed_at = <Date 2015-03-12.18:44:21.750>
    created_at = <Date 2015-03-04.09:27:01.798>
    labels = ['type-feature', 'library']
    title = "unittest.mock.MagicMock doesn't support matmul (@) operator"
    updated_at = <Date 2015-03-12.18:44:21.748>
    user = 'https://bugs.python.org/zkrynicki'

    bugs.python.org fields:

    activity = <Date 2015-03-12.18:44:21.748>
    actor = 'berker.peksag'
    assignee = 'berker.peksag'
    closed = True
    closed_date = <Date 2015-03-12.18:44:21.750>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2015-03-04.09:27:01.798>
    creator = 'zkrynicki'
    dependencies = []
    files = ['38368']
    hgrepos = []
    issue_num = 23581
    keywords = ['patch']
    message_count = 5.0
    messages = ['237176', '237434', '237435', '237972', '237973']
    nosy_count = 5.0
    nosy_names = ['python-dev', 'berker.peksag', 'zkrynicki', 'Saimadhav.Heblikar', 'H\xc3\xa5kan L\xc3\xb6vdahl']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23581'
    versions = ['Python 3.5']

    @zkrynicki
    Copy link
    Mannequin Author

    zkrynicki mannequin commented Mar 4, 2015

    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.

    @zkrynicki zkrynicki mannequin added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels Mar 4, 2015
    @HkanLvdahl
    Copy link
    Mannequin

    HkanLvdahl mannequin commented Mar 7, 2015

    Here is a suggestion for a patch. It adds the missing matmul and has a small test for it.

    @berkerpeksag
    Copy link
    Member

    Looks good. I'll tweak the patch and commit it. Thanks Håkan.

    @berkerpeksag berkerpeksag added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Mar 7, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 12, 2015

    New changeset 8c65480a1e19 by Berker Peksag in branch 'default':
    Issue bpo-23581: Add matmul support to MagicMock.
    https://hg.python.org/cpython/rev/8c65480a1e19

    @berkerpeksag
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant