Quantcast
Viewing latest article 3
Browse Latest Browse All 3

Python Unit Test - compare content of iterables in Python < 2.7

How can I check if an array of custom class is sorted in the order that I want? I know that there is assertSequenceEqual in Python 2.7 and up, but I'm using Python 2.6, and while I might be able to do this using a forloop... is there better something in Python < 2.7 that I can use?

  actual_sorted = list.sort()  expected_sorted = [MyClass("wed", 20),                      MyClass("wed", 19,),                     MyClass("thu", 18,),                     MyClass("wed", 17,)]  self.assertEqual(actual_sorted, expected_sorted) # Well, this doesn't work.

Thank you in advance!


Viewing latest article 3
Browse Latest Browse All 3

Trending Articles