Quantcast
Channel: Python Unit Test - compare content of iterables in Python < 2.7 - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by Joaquin Cuenca Abela for Python Unit Test - compare content of...

As BrenBarn said, you have to add an __eq__ method. I was writing a full example in parallel before I saw his answer:import unittestclass MyClass(object): def __init__(self, day_name, day_num):...

View Article



Answer by Marcin for Python Unit Test - compare content of iterables in...

from operator import eq as equalsself.assertTrue(all(map(equals,actual_sorted, expected_sorted)))This tests equality element-by-element. Of course, you may need to define your own equals if you do not...

View Article

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...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images