Skip to content

Test failure on Python 3.13 because it strips indents from docstrings #1937

@musicinmybrain

Description

@musicinmybrain

Expected behavior and actual behavior.

In Python 3.13 (currently in alpha), as described in https://docs.python.org/3.13/whatsnew/3.13.html, “Compiler now strip indents from docstrings.” See python/cpython#81283.

There doesn’t yet seem to be a working Python 3.13 wheel for numpy on PyPI, which makes this awkward to reproduce in a virtualenv, but we are already doing early Python 3.13 testing in Fedora Linux.

As reported in https://bugzilla.redhat.com/show_bug.cgi?id=2250678, some tests fail due to the new docstring handling.

_______________________ test_requires_geos_method[3.8.0] _______________________

version = '3.8.0', mocked_geos_version = '3.7.1', sphinx_doc_build = None

    @pytest.mark.parametrize("version", ["3.6.0", "3.8.0"])
    def test_requires_geos_method(version, mocked_geos_version, sphinx_doc_build):
        """The requires_geos decorator adjusts methods docstrings correctly"""
        wrapped = requires_geos(version)(SomeClass.func)
    
>       assert wrapped.__doc__ == expected_docstring.format(version=version, indent=" " * 8)
E       AssertionError: assert 'Docstring th...escription.\n' == 'Docstring th...on.\n        '
E           Docstring that will be mocked.
E         -         A multiline.
E         ? --------
E         + A multiline.
E           
E         -         .. note:: 'func' requires at least GEOS 3.8.0.
E         ? ------...
E         
E         ...Full output truncated (6 lines hidden), use '-vv' to show

tests/test_misc.py:123: AssertionError
=========================== short test summary info ============================
FAILED tests/test_misc.py::test_requires_geos_not_ok[3.7.2] - AssertionError:...
FAILED tests/test_misc.py::test_requires_geos_not_ok[3.8.0] - AssertionError:...
FAILED tests/test_misc.py::test_requires_geos_not_ok[3.8.1] - AssertionError:...
FAILED tests/test_misc.py::test_requires_geos_doc_build[3.6.0] - AssertionErr...
FAILED tests/test_misc.py::test_requires_geos_doc_build[3.8.0] - AssertionErr...
FAILED tests/test_misc.py::test_requires_geos_method[3.6.0] - AssertionError:...
FAILED tests/test_misc.py::test_requires_geos_method[3.8.0] - AssertionError:...
============ 7 failed, 3494 passed, 37 skipped, 3 xfailed in 5.74s =============

We expect that all tests should pass.

Steps to reproduce the problem.

Compile Shapely and run the tests on Python 3.13. (The hard part is getting a proper installation of Numpy.)

Operating system

Fedora Linux Rawhide – early testing of Python 3.13.

Shapely version and provenance

2.0.2, python-shapey


I intend to work on a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions