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 __rdivmod__ #67756

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

unittest.mock.MagicMock doesn't support __rdivmod__ #67756

zkrynicki mannequin opened this issue Mar 3, 2015 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@zkrynicki
Copy link
Mannequin

zkrynicki mannequin commented Mar 3, 2015

BPO 23568
Nosy @rbtcollins, @voidspace, @berkerpeksag
Files
  • issue23568.patch: patch and test
  • 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 = None
    closed_at = <Date 2015-03-15.00:02:16.017>
    created_at = <Date 2015-03-03.08:36:25.964>
    labels = ['type-bug', 'library']
    title = "unittest.mock.MagicMock doesn't support __rdivmod__"
    updated_at = <Date 2015-03-15.00:02:16.014>
    user = 'https://bugs.python.org/zkrynicki'

    bugs.python.org fields:

    activity = <Date 2015-03-15.00:02:16.014>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-03-15.00:02:16.017>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2015-03-03.08:36:25.964>
    creator = 'zkrynicki'
    dependencies = []
    files = ['38373']
    hgrepos = []
    issue_num = 23568
    keywords = ['patch']
    message_count = 4.0
    messages = ['237112', '237441', '238111', '238112']
    nosy_count = 6.0
    nosy_names = ['rbcollins', 'michael.foord', 'python-dev', 'berker.peksag', 'zkrynicki', 'H\xc3\xa5kan L\xc3\xb6vdahl']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23568'
    versions = ['Python 3.4', 'Python 3.5']

    @zkrynicki
    Copy link
    Mannequin Author

    zkrynicki mannequin commented Mar 3, 2015

    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

    @zkrynicki zkrynicki mannequin added the stdlib Python modules in the Lib dir label Mar 3, 2015
    @zkrynicki zkrynicki mannequin changed the title unittest.mock.MagicMock doesn't support __rdivmod__t unittest.mock.MagicMock doesn't support __rdivmod__ Mar 3, 2015
    @zkrynicki zkrynicki mannequin added the type-bug An unexpected behavior, bug, or error label Mar 3, 2015
    @HkanLvdahl
    Copy link
    Mannequin

    HkanLvdahl mannequin commented Mar 7, 2015

    I wrote a small patch and a test for it. Tested it on Python 3.5 and it worked.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 14, 2015

    New changeset 35a780a9a3b4 by Berker Peksag in branch '3.4':
    Issue bpo-23568: Add rdivmod support to MagicMock() objects.
    https://hg.python.org/cpython/rev/35a780a9a3b4

    New changeset 90f08e7fbdc3 by Berker Peksag in branch 'default':
    Issue bpo-23568: Add rdivmod support to MagicMock() objects.
    https://hg.python.org/cpython/rev/90f08e7fbdc3

    @berkerpeksag
    Copy link
    Member

    berkerpeksag commented Mar 15, 2015

    Thanks to both of you for the report and the patch.

    @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-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant