unittest2pytest icon indicating copy to clipboard operation
unittest2pytest copied to clipboard

dict(\2, **\1) requires all dictionary keys to be strings

Open verhovsky opened this issue 4 years ago • 0 comments

As https://www.python.org/dev/peps/pep-0584/#dict-d1-d2 points out,

[dict(d1, **d2)] only works when d2 is entirely string-keyed

>>> d1 = {"spam": 1}
>>> d2 = {3665: 2}
>>> dict(d1, **d2)
Traceback (most recent call last):
 ...
TypeError: keywords must be strings

So, when rewriting self.assertDictContainsSubset(a, b) as assert dict(b, **a) == b, we're introducing a test error if the dict can contain non-string keys.

verhovsky avatar May 31 '21 22:05 verhovsky