question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test faillures with python 3.10.0a6

See original GitHub issue

Fedora is starting to build python packages with Python 3.10.0a6 in its development version in order to detect problems early.

There are a few errors (very few) in testing astropy with pytest during the building process. Some of them seem related to the handling of errors (a number of them are expected to be captured but a different number of them appear).

=================================== FAILURES ===================================
___________________ TestFileFunctions.test_mmap_unwriteable ____________________

self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x7fcdda8732e0>

    def test_mmap_unwriteable(self):
        """Regression test for https://github.com/astropy/astropy/issues/968
    
        Temporarily patches mmap.mmap to exhibit platform-specific bad
        behavior.
        """
    
        class MockMmap(mmap.mmap):
            def flush(self):
                raise OSError('flush is broken on this platform')
    
        old_mmap = mmap.mmap
        mmap.mmap = MockMmap
    
        # Force the mmap test to be rerun
        _File.__dict__['_mmap_available']._cache.clear()
    
        try:
            self.copy_file('test0.fits')
            with pytest.warns(AstropyUserWarning, match=r'mmap\.flush is unavailable') as w:
                with fits.open(self.temp('test0.fits'), mode='update',
                               memmap=True) as h:
                    h[1].data[0, 0] = 999
    
>           assert len(w) == 1
E           assert 4 == 1
E            +  where 4 = len(WarningsChecker(record=True))

astropy/io/fits/tests/test_core.py:1007: AssertionError
___________________ TestHDUListFunctions.test_flush_readonly ___________________

self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x7fcdf8169300>

    def test_flush_readonly(self):
        """Test flushing changes to a file opened in a read only mode."""
    
        oldmtime = os.stat(self.data('test0.fits')).st_mtime
        with fits.open(self.data('test0.fits')) as hdul:
            hdul[0].header['FOO'] = 'BAR'
            with pytest.warns(AstropyUserWarning, match='mode is not supported') as w:
                hdul.flush()
>           assert len(w) == 1
E           assert 4 == 1
E            +  where 4 = len(WarningsChecker(record=True))

astropy/io/fits/tests/test_hdulist.py:462: AssertionError
___________________ TestHDUListFunctions.test_output_verify ____________________

self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x7fcdfdbe36d0>

    def test_output_verify(self):
        hdul = fits.HDUList([fits.PrimaryHDU()])
        hdul[0].header['FOOBAR'] = 42
        hdul.writeto(self.temp('test.fits'))
    
        with open(self.temp('test.fits'), 'rb') as f:
            data = f.read()
        # create invalid card
        data = data.replace(b'FOOBAR  =', b'FOOBAR = ')
        with open(self.temp('test2.fits'), 'wb') as f:
            f.write(data)
    
        with pytest.raises(VerifyError):
            with fits.open(self.temp('test2.fits'), mode='update') as hdul:
                hdul[0].header['MORE'] = 'here'
    
        with pytest.warns(VerifyWarning) as ww:
            with fits.open(self.temp('test2.fits'), mode='update',
                           output_verify='fix+warn') as hdul:
                hdul[0].header['MORE'] = 'here'
>       assert len(ww) == 6
E       assert 9 == 6
E        +  where 9 = len(WarningsChecker(record=True))

astropy/io/fits/tests/test_hdulist.py:1083: AssertionError
_________________________ test_read_write_format[json] _________________________

fmt = 'json'

    @pytest.mark.parametrize('fmt', WRITE_FMTS)
    def test_read_write_format(fmt):
        """
        Test round-trip through pandas write/read for supported formats.
    
        :param fmt: format name, e.g. csv, html, json
        :return:
        """
        # Skip the reading tests
        if fmt == 'html' and not HAS_HTML_DEPS:
            pytest.skip('Missing lxml or bs4 + html5lib for HTML read/write test')
    
        pandas_fmt = 'pandas.' + fmt
        # Explicitly provide dtype to avoid casting 'a' to int32.
        # See https://github.com/astropy/astropy/issues/8682
        t = Table([[1, 2, 3], [1.0, 2.5, 5.0], ['a', 'b', 'c']],
                  dtype=(np.int64, np.float64, str))
        buf = StringIO()
>       t.write(buf, format=pandas_fmt)

astropy/io/misc/tests/test_pandas.py:43: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astropy/table/connect.py:127: in __call__
    registry.write(instance, *args, **kwargs)
astropy/io/registry.py:563: in write
    writer(data, *args, **kwargs)
astropy/io/misc/pandas/connect.py:113: in _pandas_write
    return write_method(filespec, **write_kwargs)
/usr/lib64/python3.10/site-packages/pandas/core/generic.py:2465: in to_json
    return json.to_json(
/usr/lib64/python3.10/site-packages/pandas/io/json/_json.py:95: in to_json
    ).write()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pandas.io.json._json.FrameWriter object at 0x7fcddac6b670>

    def write(self):
        iso_dates = self.date_format == "iso"
>       return dumps(
            self.obj_to_write,
            orient=self.orient,
            double_precision=self.double_precision,
            ensure_ascii=self.ensure_ascii,
            date_unit=self.date_unit,
            iso_dates=iso_dates,
            default_handler=self.default_handler,
            indent=self.indent,
        )
E       ValueError: "dtype('O')" or "<class 'pandas.core.indexes.base.Index'>" are not JSON serializable yet

/usr/lib64/python3.10/site-packages/pandas/io/json/_json.py:147: ValueError
____________________________ test_warnings_logging _____________________________

    def test_warnings_logging():
    
        # Without warnings logging
        with pytest.warns(AstropyUserWarning, match="This is a warning") as warn_list:
            with log.log_to_list() as log_list:
                warnings.warn("This is a warning", AstropyUserWarning)
        assert len(log_list) == 0
        assert len(warn_list) == 1
    
        # With warnings logging
        with pytest.warns(None) as warn_list:
            log.enable_warnings_logging()
            with log.log_to_list() as log_list:
                warnings.warn("This is a warning", AstropyUserWarning)
            log.disable_warnings_logging()
        assert len(log_list) == 1
>       assert len(warn_list) == 0
E       assert 2 == 0
E        +  where 2 = len(WarningsChecker(record=True))

astropy/tests/test_logger.py:89: AssertionError
----------------------------- Captured stderr call -----------------------------
WARNING: This is a warning [astropy.tests.test_logger]
------------------------------ Captured log call -------------------------------
WARNING  astropy:logger.py:204 This is a warning
___________________ test_warnings_logging_with_custom_class ____________________

    def test_warnings_logging_with_custom_class():
        class CustomAstropyWarningClass(AstropyWarning):
            pass
    
        # With warnings logging
        with pytest.warns(None) as warn_list:
            log.enable_warnings_logging()
            with log.log_to_list() as log_list:
                warnings.warn("This is a warning", CustomAstropyWarningClass)
            log.disable_warnings_logging()
        assert len(log_list) == 1
>       assert len(warn_list) == 0
E       assert 2 == 0
E        +  where 2 = len(WarningsChecker(record=True))

astropy/tests/test_logger.py:127: AssertionError
----------------------------- Captured stderr call -----------------------------
WARNING: CustomAstropyWarningClass: This is a warning [astropy.tests.test_logger]
------------------------------ Captured log call -------------------------------
WARNING  astropy:logger.py:204 CustomAstropyWarningClass: This is a warning
_________________ test_warning_logging_with_io_votable_warning _________________

    def test_warning_logging_with_io_votable_warning():
        from astropy.io.votable.exceptions import W02, vo_warn
    
        with pytest.warns(None) as warn_list:
            log.enable_warnings_logging()
            with log.log_to_list() as log_list:
                vo_warn(W02, ('a', 'b'))
            log.disable_warnings_logging()
        assert len(log_list) == 1
>       assert len(warn_list) == 0
E       assert 2 == 0
E        +  where 2 = len(WarningsChecker(record=True))

astropy/tests/test_logger.py:142: AssertionError

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sergiopasracommented, Jun 17, 2021

We have deselected the following tests to complete the build in Fedora 35

astropy/io/fits/tests/test_core.py::TestFileFunctions::test_mmap_unwriteable
astropy/io/fits/tests/test_hdulist.py::TestHDUListFunctions::test_flush_readonly
astropy/io/fits/tests/test_hdulist.py::TestHDUListFunctions::test_output_verify
astropy/tests/test_logger.py::test_warnings_logging
astropy/tests/test_logger.py::test_warnings_logging_with_custom_class
astropy/tests/test_logger.py::test_warning_logging_with_io_votable_warning
astropy/time/tests/test_precision.py::test_sidereal_lat_independent
astropy/time/tests/test_precision.py::test_datetime_difference_agrees_with_timedelta
astropy/time/tests/test_precision.py::test_datetime_to_timedelta

The last three fail sometimes, not always

0reactions
saimncommented, Jul 20, 2021

See #11962, test failures are caused by new deprecation and runtime warnings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test failure with Python 3.10 #167 - konradhalas/dacite - GitHub
There is a test failure with Python 3.10 ... platform linux -- Python 3.10.1, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 rootdir: /build/source ...
Read more >
1944109 – python-TestSlide fails to build with Python 3.10 ...
python -TestSlide fails to build with Python 3.10.0a6. Failures: 1) patch_attribute(), when target is a StrictMock, with a template, type validation: it ...
Read more >
What's New In Python 3.10 — Python 3.11.1 documentation
This article explains the new features in Python 3.10, compared to 3.9. Python 3.10 was released on October 4, 2021. For full details,...
Read more >
Vulnerability report for Docker python:3.10.0a6-slim-buster | Snyk
Learn more about Docker python:3.10.0a6-slim-buster vulnerabilities. Docker image python has 124 known vulnerabilities found in 199 vulnerable paths.
Read more >
828998 – dev-lang/python-3.10.1 test failures: test_bdb ...
FAILED (errors=5) test test_importlib failed 7 tests failed again: test_bdb test_doctest test_import test_importlib test_pickle test_runpy ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found