Skip to content

Failures in tests with Python 3.2 - #50

Merged
astrofrog merged 1 commit into
astropy:masterfrom
mdboom:py3/test-failures
Nov 7, 2011
Merged

astrofrog merged 1 commit into
astropy:masterfrom
mdboom:py3/test-failures

Conversation

@mdboom

@mdboom mdboom commented Nov 7, 2011

Copy link
Copy Markdown
Contributor

As of 7946471, two tests have issues with Python 3.2:

============================= test session starts ==============================
platform darwin -- Python 3.2.2 -- pytest-2.1.2
collected 940 items / 1 errors 

Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/tests/tests/test_run_tests.py ..
Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/tests/tests/test_skip_remote_data.py s
Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/utils/tests/test_odict.py sssssssssssssssssssssssssssssssssssssssssss
Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/wcs/tests/test_profiling.py..................................
Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/wcs/tests/test_wcs.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................F
Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/wcs/tests/test_wcsprm.py .....................................................................................

==================================== ERRORS ====================================
 ERROR collecting Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/constants/tests/test_constant.py 
_pytest.runner:99: in __init__
>   ???
_pytest.main:290: in _memocollect
>   ???
_pytest.main:214: in _memoizedcall
>   ???
_pytest.main:290: in <lambda>
>   ???
_pytest.python:175: in collect
>   ???
_pytest.python:99: in fget
>   ???
_pytest.python:225: in _getobj
>   ???
_pytest.main:214: in _memoizedcall
>   ???
_pytest.python:230: in _importtestmodule
>   ???
py._path.local:529: in pyimport
>   ???
Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/constants/__init__.py:29: in <module>
>   for nm, val in sorted(si.__dict__.iteritems()):
E   AttributeError: 'dict' object has no attribute 'iteritems'
=================================== FAILURES ===================================
__________________________________ test_fixes __________________________________

    def test_fixes():
        """
        From github issue #36
        """
        def run():
            header = open(os.path.join(ROOT_DIR, 'data', 'nonstandard_units.hdr'),
                          'rb').read()
            w = wcs.WCS(header)

        import warnings
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            run()
>           assert len(w) == 3
E           assert 4 == 3
E            +  where 4 = len([<warnings.WarningMessage object at 0x104194650>, <warnings.WarningMessage object at 0x104194690>, <warnings.WarningMessage object at 0x1041946d0>, <warnings.WarningMessage object at 0x104194710>])

Library/Python/3.2/lib/python/site-packages/astropy-0.0dev_r255-py3.2-macosx-10.6-x86_64.egg/astropy/wcs/tests/test_wcs.py:238: AssertionError
========== 1 failed, 895 passed, 44 skipped, 1 error in 9.86 seconds ===========

@eteq and @mdboom, these relate to code you wrote in constants/init.py and wcs/tests respectively.

@eteq

eteq commented Nov 7, 2011

Copy link
Copy Markdown
Member

The constants/__init__.py error is weird... in principal the 2to3 script should have converted iteritems into items, and no fix should have been needed. But anyway, this should fix it, because items is on dictionaries in 3.x anyway (and it doesn't alter the functionality at all).

@astrofrog

Copy link
Copy Markdown
Member Author

The constants test now passes correctly, and only the WCS test is failing now.

@mdboom

mdboom commented Nov 7, 2011

Copy link
Copy Markdown
Contributor

@astrofrog: for the WCS test, you somehow have an extra warning. I'd like to see what it is. In astropy/wcs/tests/test_wcs.py:test_fixes, can you add under for item in w:, print item.message? And paste the messages displayed here?

@eteq

eteq commented Nov 7, 2011

Copy link
Copy Markdown
Member

@astrofrog: I think I know why the constants thing happened - if you take a look at http://packages.python.org/distribute/python3.html, it appears we are supposed to have use_2to3 = True as an argument in the setup function of setup.py for it to run 2to3 and convert the source code... I can add that in now in master if you like (or you can), if it won't mess up any of this.

@astrofrog

Copy link
Copy Markdown
Member Author

Ah, good catch. Feel free to add it to master!

@astrofrog

Copy link
Copy Markdown
Member Author

@mdboom - the warnings are:

unclosed file <_io.BufferedReader name='astropy/wcs/tests/data/nonstandard_units.hdr'>
'spcfix' made the change 'Unmatched celestial axes'. This FITS header contains non-standard content.
'unitfix' made the change 'Applied unit alias 'HZ      ' -> 'Hz''. This FITS header contains non-standard content.
'celfix' made the change 'Unmatched celestial axes'. This FITS header contains non-standard content.

By the way, how does one get output to print during tests? I had to write the warnings to a file to be able to view them.

@mdboom

mdboom commented Nov 7, 2011

Copy link
Copy Markdown
Contributor

@astrofrog: In my experience, whatever is written to stdout/stderr gets displayed right after the traceback with each failing test. Of course, I realised I asked you to put the print statement after the failing assert, so obviously that line never got run. In any case, see attached fix.

@astrofrog

Copy link
Copy Markdown
Member Author

It looks like all tests now pass in Python 2.6, 2.7, 3.1 and 3.2. Merging!

astrofrog added a commit that referenced this pull request Nov 7, 2011
Failures in tests with Python 3.2
@astrofrog
astrofrog merged commit dc59488 into astropy:master Nov 7, 2011
@astrofrog

Copy link
Copy Markdown
Member Author

Hmm, actually now that I've merged in the changes I'm getting another error in Python 3.1 and 3.2 which I wasn't getting with @mdboom's branch:

=================================== FAILURES ===================================
__________________________________ test_fixes __________________________________

    def test_fixes():
        """
        From github issue #36
        """
        def run():
            with open(os.path.join(ROOT_DIR, 'data', 'nonstandard_units.hdr'),
                      'rb') as fd:
                header = fd.read()
            w = wcs.WCS(header)

        import warnings
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            run()
            assert len(w) == 3
            for item in w:
                assert issubclass(item.category, wcs.FITSFixedWarning)
>               if 'unitfix' in item.message:
E   TypeError: argument of type 'FITSFixedWarning' is not iterable

astropy/wcs/tests/test_wcs.py:242: TypeError
=============== 1 failed, 897 passed, 44 skipped in 6.91 seconds ===============

Is this to do with the addition of the 2to3 option?

@mdboom mdboom reopened this Nov 7, 2011
@mdboom

mdboom commented Nov 7, 2011

Copy link
Copy Markdown
Contributor

Ah, I see it now, too. Yes, indeed it seems 2to3 broke it, but it's a simple fix. Try this commit.

@astrofrog

Copy link
Copy Markdown
Member Author

Seems to work, thanks! Merging.

astrofrog added a commit that referenced this pull request Nov 7, 2011
Failures in tests with Python 3.2
@astrofrog
astrofrog merged commit a64855f into astropy:master Nov 7, 2011
@astrofrog

Copy link
Copy Markdown
Member Author

All tests now pass in master with 2.6, 2.7, 3.1, and 3.2 on MacOS 10.6.8.

keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
@mdboom
mdboom deleted the py3/test-failures branch May 21, 2014 23:56
embray added a commit to embray/astropy that referenced this pull request Jan 23, 2015
…-ourselves

Do Sphinx version check ourselves
jeffjennings pushed a commit to jeffjennings/astropy that referenced this pull request Jul 2, 2025
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