title: How to compare two lists of objects with an assert using unittest module in Python?
body: <p>I have a method that returns a list of objects of a certain class (let's call that class A with attributes a,b c and the method my_method. So I get something like:</p>
  
  <pre><code>my_method() -&gt; [A(a1, b1, c1), A(a2, b2, c2), A(a3, b3, c3)]
  </code></pre>
  
  <p>I want to unittest this method but I don't really know which assertion method I should use to do so.</p>
  
  <p>I would like to write something like:</p>
  
  <pre><code>self.assertListEqual(my_method(), [A(a1, b1, c1), A(a2, b2, c2), A(a3, b3, c3)])
  </code></pre>
  
  <p>Notice, this line does not work (I get a failure for the test) because I think it does not work with objects list (only with basic type lists like number list). I get a:</p>
  
  <pre><code>First differing element 0
  </code></pre>
  
  <p>and a detail showing that those first objects have different adresses (which is of course normal) but it is not what I wanna compare. I just want to compare if attributes are equal (FYI, attributes a, b and c are "basic" types that is to say string or numbers)</p>
  
  <p>The order of the elements does not matter. So I want to get a failure only if both lists contains effectively different elements (and not the same in a different order). I am working with Python3. </p>
  
  <p>Thank you,</p>