pytest-dev / unittest2pytest

helps rewriting Python `unittest` test-cases into `pytest` test-cases
GNU General Public License v3.0
128 stars 27 forks source link

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

Open verhovsky opened 3 years ago

verhovsky commented 3 years ago

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.