Skip to content
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

Two tests are failing in 5.2.1 with Python 3.13.0a5 #1311

Closed
penguinpee opened this issue Mar 28, 2024 · 0 comments · Fixed by #1315
Closed

Two tests are failing in 5.2.1 with Python 3.13.0a5 #1311

penguinpee opened this issue Mar 28, 2024 · 0 comments · Fixed by #1315

Comments

@penguinpee
Copy link
Contributor

With the latest alpha release of Python 3.13 two tests are failing again. This happens in both version 5.2.0 and version 5.2.1 with Python 3.13.0a5.

In issue #1295 @sanjayankur31 reported all tests succeeding in version 5.2.0. But that was with Python 3.13.0a4.

=================================== FAILURES ===================================
_____________________ TestNibabelDeprecator.test_dep_func ______________________

self = <nibabel.tests.test_deprecated.TestNibabelDeprecator object at 0x7f7f64c8c980>

    def test_dep_func(self):
        # Test function deprecation
        dec = self.dep_func
        func = dec('foo')(func_no_doc)
        with pytest.deprecated_call():
            assert func() is None
        assert func.__doc__ == 'foo\n'
        func = dec('foo')(func_doc)
        with pytest.deprecated_call() as w:
            assert func(1) is None
            assert len(w) == 1
        assert func.__doc__ == 'A docstring\n\nfoo\n'
        func = dec('foo')(func_doc_long)
        with pytest.deprecated_call() as w:
            assert func(1, 2) is None
            assert len(w) == 1
>       assert (
            func.__doc__
            == f'A docstring\n   \n   foo\n   \n{indent(TESTSETUP, "   ", lambda x: True)}'
            f'   Some text\n{indent(TESTCLEANUP, "   ", lambda x: True)}'
        )
E       assert 'A docstring\n\nfoo\n\n\n\n.. testsetup::\n\n    >>> import pytest\n    >>> import warnings\n    >>> _suppress_warnings = pytest.deprecated_call()\n    >>> _ = _suppress_warnings.__enter__()\n\nSome text\n\n\n.. testcleanup::\n\n    >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)\n    >>> _ = _suppress_warnings.__exit__(None, None, None)\n\n' == 'A docstring\n   \n   foo\n   \n   \n   \n   .. testsetup::\n   \n       >>> import pytest\n       >>> import warnings\n       >>> _suppress_warnings = pytest.deprecated_call()\n       >>> _ = _suppress_warnings.__enter__()\n   \n   Some text\n   \n   \n   .. testcleanup::\n   \n       >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)\n       >>> _ = _suppress_warnings.__exit__(None, None, None)\n   \n'
E           A docstring
E         -    
E         -    foo
E         -    
E         -    
E         -    
E         + 
E         + foo
E         + 
E         + 
E         + 
E         -    .. testsetup::
E         ? ---
E         + .. testsetup::
E         -    
E         + 
E         -        >>> import pytest
E         ? ---
E         +     >>> import pytest
E         -        >>> import warnings
E         ? ---
E         +     >>> import warnings
E         -        >>> _suppress_warnings = pytest.deprecated_call()
E         ? ---
E         +     >>> _suppress_warnings = pytest.deprecated_call()
E         -        >>> _ = _suppress_warnings.__enter__()
E         ? ---
E         +     >>> _ = _suppress_warnings.__enter__()
E         -    
E         + 
E         -    Some text
E         ? ---
E         + Some text
E         -    
E         -    
E         + 
E         + 
E         -    .. testcleanup::
E         ? ---
E         + .. testcleanup::
E         -    
E         + 
E         -        >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)
E         ? ---
E         +     >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)
E         -        >>> _ = _suppress_warnings.__exit__(None, None, None)
E         ? ---
E         +     >>> _ = _suppress_warnings.__exit__(None, None, None)
E         -    
E         +

nibabel/tests/test_deprecator.py:95: AssertionError
_______________________ TestDeprecatorFunc.test_dep_func _______________________

self = <nibabel.tests.test_deprecator.TestDeprecatorFunc object at 0x7f7f64c8f7a0>

    def test_dep_func(self):
        # Test function deprecation
        dec = self.dep_func
        func = dec('foo')(func_no_doc)
        with pytest.deprecated_call():
            assert func() is None
        assert func.__doc__ == 'foo\n'
        func = dec('foo')(func_doc)
        with pytest.deprecated_call() as w:
            assert func(1) is None
            assert len(w) == 1
        assert func.__doc__ == 'A docstring\n\nfoo\n'
        func = dec('foo')(func_doc_long)
        with pytest.deprecated_call() as w:
            assert func(1, 2) is None
            assert len(w) == 1
>       assert (
            func.__doc__
            == f'A docstring\n   \n   foo\n   \n{indent(TESTSETUP, "   ", lambda x: True)}'
            f'   Some text\n{indent(TESTCLEANUP, "   ", lambda x: True)}'
        )
E       assert 'A docstring\n\nfoo\n\n\n\n.. testsetup::\n\n    >>> import pytest\n    >>> import warnings\n    >>> _suppress_warnings = pytest.deprecated_call()\n    >>> _ = _suppress_warnings.__enter__()\n\nSome text\n\n\n.. testcleanup::\n\n    >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)\n    >>> _ = _suppress_warnings.__exit__(None, None, None)\n\n' == 'A docstring\n   \n   foo\n   \n   \n   \n   .. testsetup::\n   \n       >>> import pytest\n       >>> import warnings\n       >>> _suppress_warnings = pytest.deprecated_call()\n       >>> _ = _suppress_warnings.__enter__()\n   \n   Some text\n   \n   \n   .. testcleanup::\n   \n       >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)\n       >>> _ = _suppress_warnings.__exit__(None, None, None)\n   \n'
E           A docstring
E         -    
E         -    foo
E         -    
E         -    
E         -    
E         + 
E         + foo
E         + 
E         + 
E         + 
E         -    .. testsetup::
E         ? ---
E         + .. testsetup::
E         -    
E         + 
E         -        >>> import pytest
E         ? ---
E         +     >>> import pytest
E         -        >>> import warnings
E         ? ---
E         +     >>> import warnings
E         -        >>> _suppress_warnings = pytest.deprecated_call()
E         ? ---
E         +     >>> _suppress_warnings = pytest.deprecated_call()
E         -        >>> _ = _suppress_warnings.__enter__()
E         ? ---
E         +     >>> _ = _suppress_warnings.__enter__()
E         -    
E         + 
E         -    Some text
E         ? ---
E         + Some text
E         -    
E         -    
E         + 
E         + 
E         -    .. testcleanup::
E         ? ---
E         + .. testcleanup::
E         -    
E         + 
E         -        >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)
E         ? ---
E         +     >>> warnings.warn("Avoid error if no doctests to run...", DeprecationWarning)
E         -        >>> _ = _suppress_warnings.__exit__(None, None, None)
E         ? ---
E         +     >>> _ = _suppress_warnings.__exit__(None, None, None)
E         -    
E         +

nibabel/tests/test_deprecator.py:95: AssertionError
penguinpee added a commit to penguinpee/nibabel that referenced this issue Apr 1, 2024
- Dedent docstrings in Python 3.13+
- Fix nipy#1311
- Ref: python/cpython#81283
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 a pull request may close this issue.

1 participant