[New-bugs-announce] [issue22318] unitest documentation on assertItemsEqual misleading

Tony Flury 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
components: Documentation
messages: 226193
nosy: TonyFlury, docs at python
priority: normal
severity: normal
status: open
title: unitest documentation on assertItemsEqual misleading
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22318>
_______________________________________


More information about the New-bugs-announce mailing list