title: Why doesn't unittest.mock.ANY work correctly with Django objects?
body: <p>I have written a test in Django, and I'm <a href="https://stackoverflow.com/a/57627010/247696">using <code>unittest.mock.ANY</code> to ignore certain values in a dictionary</a>. Here is the test:</p>
  
  <pre class="lang-py prettyprint-override"><code>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}
          )
  </code></pre>
  
  <p>If I run this test, I expect it to pass. Instead, I get this failure:</p>
  
  <pre><code>======================================================================
  FAIL: test_example (example.tests.Example)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "example/tests.py", line 18, in test_example
      'number': 42,
  AssertionError: {'user': &lt;User: example&gt;, 'number': 42} != {'user': &lt;ANY&gt;, 'number': 42}
  - {'number': 42, 'user': &lt;User: example&gt;}
  ?                         ^^^^^^^^^^^^^
  
  + {'number': 42, 'user': &lt;ANY&gt;}
  ?                         ^^^
  </code></pre>
  
  <p>Why doesn't <a href="https://docs.python.org/3/library/unittest.mock.html#any" rel="nofollow noreferrer"><code>ANY</code></a> work in this case? It seems to work with strings and numbers.</p>