Given
l1 = [a,b]
l2 = [b,a]
In Python >= 3.0
assertCountEqual(l1, l2) # True
In Python >= 2.7, the above function was named:
assertItemsEqual(l1, l2) # True
In Python < 2.7
import unittest2
assertItemsEqual(l1, l2) # True
Via six module (Any Python version)
import unittest
import six
class MyTest(unittest.TestCase):
def test(self):
six.assertCountEqual(self, self.l1, self.l2) # True