[issue15810] assertSequenceEqual should be fired when comparing sequence subclasses

2012-08-31 Thread Gregory P. Smith

Gregory P. Smith added the comment:

When we added this functionality to assertEqual we were *intentionally* 
conservative on when it would auto-promote to nicer equality comparison 
functions.  It needs to behave exactly as == would in all situations.

 (1,2,3) == [1,2,3]
False

We must maintain that behavior in assertEqual.

Tests should use assertSequenceEqual when they want to compare sequences 
regardless of type because they are testing for something less than strict 
equality.

--
nosy: +gregory.p.smith
resolution:  - rejected
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15810
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15810] assertSequenceEqual should be fired when comparing sequence subclasses

2012-08-29 Thread R. David Murray

R. David Murray added the comment:

That sounds like a bug.

--
title: assertSequenceEqual should be fired when comparing sequences - 
assertSequenceEqual should be fired when comparing sequence subclasses

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15810
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15810] assertSequenceEqual should be fired when comparing sequence subclasses

2012-08-29 Thread Ezio Melotti

Ezio Melotti added the comment:

The assertSequenceEqual docs[0] say:

This method is not called directly by assertEqual(), but it’s used to implement 
assertListEqual() and assertTupleEqual().


The asserEqual docs[1] say:

In addition, if first and second are the exact same type and one of list, 
tuple, dict, set, frozenset or str or any type that a subclass registers with 
addTypeEqualityFunc() the type-specific equality function will be called in 
order to generate a more useful default error message (see also the list of 
type-specific methods).


assertEqual[2] calls _getAssertEqualityFunc[3] that checks if type(first) is 
type(second), so in your case no specific assert function is called, and since 
you are not comparing objects of the same type, you are not able to use 
addTypeEqualityFunc() either.

I think in this case using assertSequenceEqual() directly is ok.

[0]: 
http://docs.python.org/py3k/library/unittest.html#unittest.TestCase.assertSequenceEqual
[1]: 
http://docs.python.org/py3k/library/unittest.html#unittest.TestCase.assertEqual
[2]: http://hg.python.org/cpython/file/124fb2b39ed9/Lib/unittest/case.py#l637
[3]: http://hg.python.org/cpython/file/124fb2b39ed9/Lib/unittest/case.py#l604

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15810
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com