[docs] [issue22318] unitest documentation on assertItemsEqual misleading
report at bugs.python.org
Sun Aug 31 23:55:54 CEST 2014
New submission from Tony Flury:
The notes on assertItemsEqual do not make it clear that the comparison works by using their hash value, and not their __eq__ implementation - i.e. it does an 'is' not an '==' between objects in the sequence.
If the sequences being compared contain user created objects which don't implement their own specific __hash__ method (and therefore inherit their __hash__ from the base object - based on the object id), then the assertion will ALWAYS be false, regardless of their __eq__ value.
This only became clear when trying to use unitest, getting strange results, and I eventually read the code.
assignee: docs at python
nosy: TonyFlury, docs at python
title: unitest documentation on assertItemsEqual misleading
versions: Python 2.7
Python tracker <report at bugs.python.org>
More information about the docs