Unittest’s assertEqual and iterables – only check the contents

Python 3

  • If you don’t care about the order of the content, you have the assertCountEqual(a,b) method
  • If you care about the order of the content, you have the assertSequenceEqual(a,b) method

Python >= 2.7

  • If you don’t care about the order of the content, you have the assertItemsEqual(a,b) method
  • If you care about the order of the content, you have the assertSequenceEqual(a,b) method

Leave a Comment