testing-cabal / unittest-ext

Automatically exported from code.google.com/p/unittest-ext
2 stars 2 forks source link

assertItemsEqual doesn't work for items without a sort() method #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Trying to use assertItemsEqual on a class without a sort attribute (such as 
django's ValuesQuerySet) can raise an AttributeError instead of a TypeError.

Catching the AttributeError in addition to the TypeError fixes the problem.

Original issue reported on code.google.com by paulrmcmillanold on 2 Jul 2010 at 5:39

GoogleCodeExporter commented 9 years ago
Sounds like an easy fix, unfortunately too late for Python 2.7. I'll do one 
more release with Python 2.7 feature parity and then add new features. Arguably 
this is a bugfix and could go into 2.7.1 anyway.

Original comment by fuzzyman on 5 Jul 2010 at 10:06

GoogleCodeExporter commented 9 years ago
Why catch AttributeError, why not just use list(x); .sort() (since I assume 
sorted isn't available)?

Original comment by alex.gay...@gmail.com on 6 Jul 2010 at 1:27

GoogleCodeExporter commented 9 years ago
sorted is available now. But we listify anyhow, so closed.

Original comment by robert.c...@gmail.com on 7 Nov 2014 at 10:24