Skip to content

Test with 2to3 - #56

Merged
eteq merged 2 commits into
astropy:masterfrom
embray:test-with-2to3
Nov 9, 2011
Merged

eteq merged 2 commits into
astropy:masterfrom
embray:test-with-2to3

Conversation

@embray

@embray embray commented Nov 7, 2011

Copy link
Copy Markdown
Member

Adds support for running the tests in Python 3 after they've been run through 2to3. I tried doing this through a subclass of setuptools' builtin test command as discussed in another thread, but it just wasn't working out as I'd hoped. Rather than fight with it, it was faster to keep the code mostly as it is: then adding 2to3 support was simply a matter of ensuring that 2to3 is called first, and that the tests are run out of the 2to3'd build.

As a bonus, I added a test that tests that the tests are 2to3'd :) This was necessary since none of the tests currently in master actually require 2to3.

…good since the entire thing is parsed at import time. This is the right way to do this. And of course if and when we do add tests that need to be 2to3'd, if this test fails they're all going to fial too. But it's still nice to have...
embray added a commit to embray/astropy that referenced this pull request Nov 8, 2011
…ted 3.1). The tests will only work if you try this on top of my pull request at astropy#56 which adds 2to3 support to the setup.py test command.  There are still two tests that fail for me under Python 3, but I know I've fixed that problem in PyFITS's SVN trunk, so I just need to merge that in.
@eteq

eteq commented Nov 8, 2011

Copy link
Copy Markdown
Member

One oddity I've noticed here: Before this, python setup.py develop followed by python setup.py test works fine, and the only thing I see in build is the build/tmp... directory. After this change, doing the exact same thing populates build/lib... with a bunch of files. Presumably this is because the build command now gets run. I don't really care too much whether or not there's files in build, but I just wanted to make sure this is expected behavior.

@embray

embray commented Nov 8, 2011

Copy link
Copy Markdown
Member Author

Yes, this would be expected. On Python 2 it's not necessary to do the build_py command at all, and in fact I could just take it out. But for 2to3 it is necessary. I just figure leave it in even for Python 2--there's no harm in it really, and it's more consistent that way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the import not inside of the test itself. This will cause the number of tests to change which is a problem for automated testing frameworks that want to track status from one run to the next (like Pandokia). Would this work?:

def test_run_after_2to3():
    try:
        from .run_after_2to3 import test_run_after_2to3
    except SyntaxError:
        helper.pytest.fail("Not running the 2to3'd tests!")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could work either way, but I liked it this way because the thing that's being imported is the test itself. That is, we're testing that a test can be tested...if that makes any sense. The number of tests doesn't change, because either way a test called "test_run_after_2to3" gets added to the test collection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I get it. Subtle, but makes sense.

eteq added a commit that referenced this pull request Nov 9, 2011
Adds support to the setup.py test command to run 2to3 under python 3.x
@eteq
eteq merged commit 5ca66c9 into astropy:master Nov 9, 2011
embray added a commit to embray/astropy that referenced this pull request Nov 21, 2011
…ted 3.1). The tests will only work if you try this on top of my pull request at astropy#56 which adds 2to3 support to the setup.py test command.  There are still two tests that fail for me under Python 3, but I know I've fixed that problem in PyFITS's SVN trunk, so I just need to merge that in.
embray added a commit to embray/astropy that referenced this pull request Jan 31, 2012
…ted 3.1). The tests will only work if you try this on top of my pull request at astropy#56 which adds 2to3 support to the setup.py test command.  There are still two tests that fail for me under Python 3, but I know I've fixed that problem in PyFITS's SVN trunk, so I just need to merge that in.
keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
Adds support to the setup.py test command to run 2to3 under python 3.x
keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
…ted 3.1). The tests will only work if you try this on top of my pull request at astropy#56 which adds 2to3 support to the setup.py test command.  There are still two tests that fail for me under Python 3, but I know I've fixed that problem in PyFITS's SVN trunk, so I just need to merge that in.
jeffjennings pushed a commit to jeffjennings/astropy that referenced this pull request Jul 2, 2025
Add spherical-geometry affiliated package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants