Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
python3 compatibility #185
Not everything is converted. Test results:
As you can see, tests import fine under Python 3.5, and there's only a few more failures. A bunch of tests fail because of bytes/str incompatiblity under Python 3. This is in the testing code, and I don't know what the proper solution is, so I left this alone.
mirrorlist/mirrorlist_client.wsgi runs, mirrorlist/mirrorlist_server.py fails with GeoIP import which I can't easy obtain.
I forgot that python2 doesn't have the builtins module, and it is provided by python2-future rpm. Using future is a bit more convenient, but in this case it's not worth the depenency, I think. I'll rework the patch to simply use normal range under python2, in this case it really doesn't matter.
From what I could tell, the test suite has only partial coverage, so it's not going to provide any kind of certainty anyway, unless it is significantly extended and reworked.
Most of those patches are to imports and syntax, so they're relatively safe: if they fail, they fail at import time, so if the code actually loads, it most likely works correctly too.
master @ today:
In my 3k branch with the following patch on top:
And again, a bunch of failures are because of bytes/str issues:
A lot of those would probably go away if the tests were changed to use
Oh, I found one more thing to fix:
@keszybz: are you still interested in this PR? The test suite is functional again since a few months and I would like to merge this if you would rebase. If this is too old and you do not care about it anymore (understandable after almost two years) I would also cherry-pick your commits and fixup the commits with the conflicts manually.
For those uses there is no practical difference between range and xrange (no big ranges are used), so just get rid of xrange. Signed-off-by: Zbigniew Jędrzejewski-Szmek <email@example.com>
… and from __future__ import print_function for python2 compat. Signed-off-by: Zbigniew Jędrzejewski-Szmek <firstname.lastname@example.org>
futurize-3 -w -n -p -f libfuturize.fixes.fix_absolute_import . Signed-off-by: Zbigniew Jędrzejewski-Szmek <email@example.com>
2to3 doesn't know that those objects are a dict too and does not apply the fixer. Signed-off-by: Zbigniew Jędrzejewski-Szmek <firstname.lastname@example.org>
tests/test_ui_app.py::FlaskUiAppTest::test_site_new /home/zbyszek/python/mirrormanager2/tests/../mirrormanager2/app.py:288: FlaskWTFDeprecationWarning: "flask_wtf.Form" has been renamed to "FlaskForm" and will be removed in 1.0. form = forms.AddSiteForm() Signed-off-by: Zbigniew Jędrzejewski-Szmek <email@example.com>
This makes tests/test_umdl.py and tests/test_mdtr.py pass under python3. Signed-off-by: Zbigniew Jędrzejewski-Szmek <firstname.lastname@example.org>
This fixes tests/test_crawler.py under python3. Signed-off-by: Zbigniew Jędrzejewski-Szmek <email@example.com>
This is the right thing to do according to pallets/flask#716. — data is intentionally the undecoded bytes, and we need to either decode it outselves, our use .get_data(as_text=True). This latter seems to be a nicer option. I used temporary 'data' variable to assign the decoded text. .get_data() is caching by default, so this doesn't save much work, but avoid the fairly verbose method invocation in asserts. In some places 'data' was used for .post(), and this is renamed to 'post_data' to avoid the name clash. This makes all tests pass under python3. Signed-off-by: Zbigniew Jędrzejewski-Szmek <firstname.lastname@example.org>
It's a drop-in replacement and imho the best option currently. (There's probably some niche stuff that is not entirely compatible, but pytest supports pretty much everything that the built-in