Skip to content

Test faillures with python 3.10.0a6 #11821

@sergiopasra

Description

@sergiopasra

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    zzz 💤 Python3.10archived: Python 3.10 is no longer supported

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions