I have written a test in Django, and I\'m using unittest.mock.ANY to ignore certain values in a dictionary. Here is the test:
assertEqual, in the course of comparing its two arguments, evaluates the expression user == mock.ANY. In standard fashion, the left argument determines which function actually implements ==. In this case, you have user.__eq__(mock.ANY). It appears that whatever type user is, its __eq__ method simply returns False for an unexpected type. If it raised NotImplemented instead, the language would fall back on mock.ANY.__eq__(user), which could return True.
If you change the call to
self.assertEqual(
{'user': mock.ANY, 'number': 42},
result,
)
then the resulting comparison mock.ANY == user will return True as expected.