Why doesn't unittest.mock.ANY work correctly with Django objects?
问题 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: from django.test import TestCase from django.contrib.auth import get_user_model import unittest.mock as mock class Example(TestCase): def test_example(self): user = get_user_model().objects.create_user(username='example') result = {'user': user, 'number': 42} self.assertEqual( result, {'user': mock.ANY, 'number': 42} ) If I run this test, I expect it to pass. Instead, I