-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Python 2 and Python 3 with single source #1
Conversation
This idiom works in Python 3 and in Python 2, including < 2.6 unlike the `as` syntax that only works in Python >= 2.6 --HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
…quotes around module name in exception message for Python >= 3.3 --HG-- branch : py2_and_py3_single_source
that causes a test failure in Python 3 --HG-- branch : py2_and_py3_single_source
AttributeError: 'str' object has no attribute 'decode' --HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
by copying code from unittest2py3k This fixes the final test failure (Test_TestLoader.test_loadTestsFromNames__callable__call_staticmethod) --HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
--HG-- branch : py2_and_py3_single_source
🍻 |
❤️ |
--HG-- branch : py2_and_py3_single_source
Folks who are interested in this PR might also be interested in this package which I uploaded to PyPI yesterday: https://pypi.python.org/pypi/unittest2six It's a simple meta package to easily get unittest2 functionality in both Python 2 and Python 3. On Python 2, it |
@voidspace: Any thoughts on this one? |
is this fixed or forgotten? |
This is fixed in unittest2 source. |
🍻 |
Patch Set 10: Darragh wrote: > just spotted that the introduction of unittest2 causes problems with python3, probably because the python3 compatible version is called unittest2py3k on pypi. Good catch! I've run into this a number of times with various projects, so a few months ago I created a "meta-package" called "unittest2six" on PyPI: https://pypi.python.org/pypi/unittest2six It's one package that's installable on both Python 2 and Python 3. I also have a PR open to make unittest2 work natively on Python 3, thus eliminating the need for unittest2py3k -- if you like the idea, you might want to +1 the PR: msabramo/unittest2#1 Patch-set: 10 Label: Verified=0
Travis CI:
Drone.io:
Right now you have to install
unittest2
for Python 2 andunittest2py3k
for Python 3.This is a little clunky when using pip requirements files and tox because you have to have two separate requirements files and two separate tox targets. E.g.:
# test-requirements-py2.txt unittest2 mock lxml
# test-requirements-py3.txt unittest2py3k mock lxml
It would be nice if there were one package that supported both.
Google Code issue: https://code.google.com/p/unittest-ext/issues/detail?id=81
Bitbucket (hg) branch: https://bitbucket.org/msabramo/unittest2/branch/py2_and_py3_single_source
GitHub branch: https://github.com/msabramo/unittest2/tree/bm/py2_and_py3_single_source
Successful Drone.io build: https://drone.io/bitbucket.org/msabramo/unittest2/5
Passing Travis CI build: https://travis-ci.org/msabramo/unittest2/builds/24631644
😄
Cc: @voidspace