[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Concur with Eric and Raymond.

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I agree with Eric that this should not be changed.  It is working as documented 
and intended.

In its original incarenation, assertCountEqual was documented as being 
equivalent to ``assertEqual(sorted(expected), sorted(actual))``.  Either way, 
the goal was to count the values produced by iterating.

To compare two dicts or two Counters including both keys and values, just use 
assertEqual.

--
nosy: +rhettinger

___
Python tracker 

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



[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Can


Can  added the comment:

@sobolevn I was expecting the following test case to be covered.

self.assertRaises(self.failureException, self.assertCountEqual,
  {'a': 1}, {'a': 2})

what I understand from the doc of the assertion is that elements have to be the 
same without regard to order. The doc can be extended for dict.

In [10]: d = {"key": "value"}

In [11]: collections.Counter(list(d))
Out[11]: Counter({'key': 1})

In [12]: collections.Counter(d.items())
Out[12]: Counter({('key', 'value'): 1})

--

___
Python tracker 

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



[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Eric V. Smith


Eric V. Smith  added the comment:

The PR changes the meaning of assertCountEqual. 
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertCountEqual
 says: Equivalent to: assertEqual(Counter(list(first)), Counter(list(second))) 
...

At the very least, the documentation would need to be updated. But since this 
could be a breaking change, I don't think it will be accepted.

--
nosy: +eric.smith

___
Python tracker 

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



[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Can


Change by Can :


--
keywords: +patch
pull_requests: +29261
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31077

___
Python tracker 

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



[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
components: +Library (Lib)
versions: +Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Nikita Sobolev


New submission from Nikita Sobolev :

@cansarigol, can you please specify what do you expect and how it works?

--
nosy: +sobolevn

___
Python tracker 

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



[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Can


Change by Can :


--
nosy: cansarigol
priority: normal
severity: normal
status: open
title: assertCountEqual doesn't work as expected for dictionary elements
type: behavior

___
Python tracker 

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