title: Assert that two lists of objects are equal in django testing
body: <p>Is there a way to check that two lists of objects are equal in django tests.</p>
  
  <p>lets say I have some model:</p>
  
  <pre><code>class Tag(models.Model):
      slug = models.SlugField(max_length=50, unique=True)
      def __unicode__(self):
          return self.slug
  </code></pre>
  
  <p>and I run this simple test:</p>
  
  <pre><code>def test_equal_list_fail(self):
      tag_list = []
      for tag in ['a', 'b', 'c']:
          tag_list.append(Tag.objects.create(slug=tag))
  
      tags = Tag.objects.all()
  
      self.assertEqual(tag_list, tags)
  </code></pre>
  
  <p>this fails with:</p>
  
  <pre><code>======================================================================
  FAIL: test_equal_list_fail (userAccount.tests.ProfileTests)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "path/to/tests.py", line 155, in test_equal_list_fail
      self.assertEqual(tag_list, tags)
  AssertionError: [&lt;Tag: a&gt;, &lt;Tag: b&gt;, &lt;Tag: c&gt;] != [&lt;Tag: a&gt;, &lt;Tag: b&gt;, &lt;Tag: c&gt;]
  
  ----------------------------------------------------------------------
  </code></pre>
  
  <p>this will work:</p>
  
  <pre><code>def test_equal_list_passes(self):
      tag_list = []
      for tag in ['a', 'b', 'c']:
          tag_list.append(Tag.objects.create(slug=tag))
  
      tags = Tag.objects.all()
  
      for tag_set in zip(tags, tag_list):
          self.assertEqual(*tag_set)
  </code></pre>
  
  <p>However, This fails:</p>
  
  <pre><code>def test_equal_list_fail(self):
      tag_list = []
      for tag in ['a', 'b', 'c']:
          tag_list.append(Tag.objects.create(slug=tag))
  
      tags = Tag.objects.all()
  
      for tag_set in zip(tags, tag_list):
          print "\n"
          print tag_set[0].slug + "'s pk is %s" % tag_set[0].pk
          print tag_set[1].slug + "'s pk is %s" % tag_set[1].pk
          print "\n"
          self.assertIs(*tag_set)
  </code></pre>
  
  <p>with:  </p>
  
  <pre><code>Creating test database for alias 'default'...
  .......
  
  a's pk is 1
  a's pk is 1
  
  F.
  ======================================================================
  FAIL: test_equal_list_fail (userAccount.tests.ProfileTests)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "path/to/tests.py", line 160, in test_equal_list_fail
      self.assertIs(*tag_set)
  AssertionError: &lt;Tag: a&gt; is not &lt;Tag: a&gt;
  </code></pre>
  
  <p><strong>Is this expected behavior?</strong> </p>
  
  <p><strong>Edit</strong> in response to comment<br>
  This type of comparison works:</p>
  
  <pre><code>class Obj:
      def __init__(self, x):
          self.x = x
  
  &gt;&gt;&gt; one = Obj(1)
  &gt;&gt;&gt; two = Obj(2)
  &gt;&gt;&gt; a = [one, two]
  &gt;&gt;&gt; b = [one, two]
  &gt;&gt;&gt; a == b
  True
  </code></pre>
  
  <p>Why is the test failing for the other arrays?</p>