[issue25669] unittest.assertEqual() on un-equal types inheriting from collections.Mapping

2015-11-23 Thread Michael Foord

Michael Foord added the comment:

assertEqual *does* do type checking and it's strict that it will only resort to 
the "type specific" assert checks if both types are of the same type. In the 
general case it's impossible to know whether comparing a subclass with the type 
specific check is the right thing to do - so unittest doesn't guess.

As you have a simple workaround ( dict(foo) ) I'm closing this.

--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25669] unittest.assertEqual() on un-equal types inheriting from collections.Mapping

2015-11-20 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +ezio.melotti, michael.foord, rbcollins

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25669] unittest.assertEqual() on un-equal types inheriting from collections.Mapping

2015-11-20 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25669] unittest.assertEqual() on un-equal types inheriting from collections.Mapping

2015-11-20 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
versions: +Python 3.6 -Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25669] unittest.assertEqual() on un-equal types inheriting from collections.Mapping

2015-11-19 Thread Nathan Herring

Nathan Herring added the comment:

FWIW, it's also pretty easy to write

self.assertEqual({'key': 'value'}, dict(foo))

and get the right behavior, but it'd be nice if it was done automagically by 
type checking.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25669] unittest.assertEqual() on un-equal types inheriting from collections.Mapping

2015-11-19 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25669] unittest.assertEqual() on un-equal types inheriting from collections.Mapping

2015-11-19 Thread Nathan Herring

New submission from Nathan Herring:

We have some code that generates objects that inherit from Mapping that are not 
nearly as straightforward to instantiate in a test. It's much easier to have 
something like the follows:

foo = … # some collections.Mapping subtype
self.assertEqual({'key': 'value'}, foo)

unittest/case.py's _baseAssertEqual will print out both sides and let me do 
visual inspection, but I'd prefer it if it knew both sides supported Mapping 
and in the != case, performed an analog of assertDictEqual so I could just get 
the keys/values that were mismatched, especially in the cases of large 
dictionaries.

--
components: Tests
messages: 254902
nosy: Nathan Herring
priority: normal
severity: normal
status: open
title: unittest.assertEqual() on un-equal types inheriting from 
collections.Mapping
type: enhancement
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com