[New-bugs-announce] [issue40909] unittest assertCountEqual doesn't filter on values in dict

Emil Bode report at bugs.python.org
Mon Jun 8 07:25:50 EDT 2020


New submission from Emil Bode <BodeEmil at gmail.com>:

Found as a comment on SO (https://stackoverflow.com/questions/12813633/how-to-assert-two-list-contain-the-same-elements-in-python#comment104082703_31832447):

In unittest, `self.assertCountEqual({1: [1, 2, 3]}, {1: [5, 6, 7]})` succeeds, even though the two are different.
In this simple case, using assertCountEqual is unnecessary, but there may be cases where a user wants to test for general equality regardless of order.

Note that `self.assertCountEqual([{1: [1, 2, 3]}], [{1: [5, 6, 7]}])` (where both are a list, with only a dict-element), does fail.
And comparing 2 dicts with different keys also fails as expected.

----------
components: Library (Lib)
messages: 370973
nosy: EmilBode
priority: normal
severity: normal
status: open
title: unittest assertCountEqual doesn't filter on values in dict
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40909>
_______________________________________


More information about the New-bugs-announce mailing list