Skip to content

Mock is equal to ANY but MagicMock is not #384

Description

@rafaelcaricio

The instances of mock.Mock() are equal to mock.ANY, but mock.MagicMock() instances are not.

Minimal example:

In Python 3.5.2 (or mock 2.0.0):

>>> from unittest import mock
>>> mock.Mock() == mock.ANY
True
>>> mock.ANY == mock.Mock()
True
>>> mock.MagicMock() == mock.ANY
False
>>> mock.ANY == mock.MagicMock()
True

I have opened an issue in the official Python tracker, but probably here is the most appropriated place to that. Please let me know if I should close it and just leave this one here.

ref: http://bugs.python.org/issue28735

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions