unittest2pytest icon indicating copy to clipboard operation
unittest2pytest copied to clipboard

Allow non-string keys when rewriting assertDictContainsSubset

Open verhovsky opened this issue 4 years ago • 4 comments

and also update supported Python versions in tox.ini.

#54

verhovsky avatar May 31 '21 23:05 verhovsky

I guess {**a, **b} is not supported on Python 2. One tricky thing is that dict(a, **b) actually works in Python 2. We will have to either drop Python 2 support or have a flag like --py2 (and --py3?) to enable that. While we're doing this, we might as well add a --py39 because on 3.9 you can do a | a == a.

verhovsky avatar Jun 01 '21 22:06 verhovsky

Thanks @verhovsky!

My 2 cents:

I think dropping Python 2 is fine, and then we always use the Python 3 syntax ({**a, **b}).

If not, not sure we need a flag, we might just use the version of the Python we are running (sys.version_info).

nicoddemus avatar Jun 02 '21 11:06 nicoddemus

use the version of the Python we are running

If someone doesn't realize their pip command is Python 2 pip and does pip install unittest2pytest, they will run into this bug when they run unittest2pytest <whatever>. In a way dropping Python 2 support has the same effect, since installing unittest2pytest under Python 2 will install the last version, which is the one that rewrites it as dict(b, **a).

I also dropped Python 3.5 which is unsupported since 2020-09, I hope that's fine.

verhovsky avatar Jun 02 '21 12:06 verhovsky

LGTM!

This also warrants a changelog entry. 👍

nicoddemus avatar Jun 02 '21 14:06 nicoddemus