title: django testing Assertquerysetequal not working
body: <p>I have trying to do an <code>assertQuerysetEqual</code> with django testing using the following commands but all of them work if there is only one object in the list, but when I insert multiple objects in the list to compare both sets of queries all of them fail sometimes and pass sometimes which is completely strange(running with same set of code). The list of <code>assertQuerysetEqual</code> I used to test I sourced from two other questions in <a href="https://stackoverflow.com/questions/17685023/how-do-i-test-django-querysets-are-equal">How do I test Django QuerySets are equal?</a> and in <a href="https://stackoverflow.com/questions/11610943/django-1-4-assertquerysetequal-how-to-use-method?noredirect=1&amp;lq=1">Django 1.4 - assertQuerysetEqual - how to use method</a> as well as the django documentation.</p>
  
  <p>This could be because the sequence is not in order when it fails the comparison test. Because when I did a print - my querysets were exactly matching. Because when I run the tests, sometimes the tests passes, sometimes it fails when I compare multiple objects in my lists. I can tell them the list differ when it fails because of the error message but I don't understand why the commands that I used does not compare them in order. (They were accepted/upvoted answers)</p>
  
  <p>Any advice on how I can fix this permanently would be welcome. Thank you.</p>
  
  <pre><code>class TestViews(TestCase):
  
      def setUp(self):
          self.client = Client()
  
          self.user = User.objects.create_user(
              username='normaluser', email='s@gmail.com', password='secret123')
  
          self.notcreateuser = User.objects.create_user(
              username='notcreateuser', email='s@gmail.com', password='secret123')
  
          self.adminuser = User.objects.create_user(
              username='adminuser', email='s@gmail.com', password='secret123', is_staff=True)
  
          obj_puser = mixer.blend('users.PUser', user=self.user)
          obj_puser_oth = mixer.blend('users.PUser', user=self.notcreateuser)
          obj_puser_staff = mixer.blend('users.PUser', user=self.adminuser)
  
          obj_ptype = mixer.blend('polls.Ptype', active=True)
          obj_pitem0 = mixer.blend('polls.PollItem', polltype=obj_ptype, user_submit=self.user, allowed=True)
          obj_pitem1 = mixer.blend('polls.PollItem', polltype=obj_ptype, user_submit=self.user, allowed=True)
  
      def test_poll_list_view_query(self):
          self.client.login(username="normaluser", password="secret123")
          ptype_obj = Ptype.objects.get(pk__in=[1])
          path = "/polls/"
          data = {'type': ptype_obj.slug }
          res = self.client.get(path, data)
  
  
          pitemlist = PollItem.objects.filter(pk__in=[1,2])
  
          #list of assertQuerysetEqual I am testing
          self.assertQuerysetEqual(res.context['object_list'], [repr(r) for r in pitemlist])
          self.assertQuerysetEqual(res.context['object_list'], pitemlist, transform=lambda x:x)
          self.assertQuerysetEqual(res.context['object_list'], map(repr, pitemlist))
  </code></pre>