python-attrs / attrs

Python Classes Without Boilerplate
https://www.attrs.org/
MIT License
5.3k stars 374 forks source link

Test failures with Python 3.13: stripped indentation from docstrings #1228

Closed befeleme closed 8 months ago

befeleme commented 9 months ago

In Python 3.13, compiler strips indents from docstrings. See https://github.com/python/cpython/issues/81283

_______________________ TestDundersUnnamedClass.test_ne ________________________

self = <tests.test_cmp.TestDundersUnnamedClass object at 0x7f8f99705280>

    def test_ne(self):
        """
        __ne__ docstring and qualified name should be well behaved.
        """
        method = self.cls.__ne__
>       assert method.__doc__.strip() == (
            "Check equality and either forward a NotImplemented or\n"
            "        return the result negated."
        )
E       AssertionError: assert 'Check equality and either forward a NotImplemented or\nreturn the result negated.' == 'Check equality and either forward a NotImplemented or\n        return the result negated.'
E           Check equality and either forward a NotImplemented or
E         -         return the result negated.
E         ? --------
E         + return the result negated.

tests/test_cmp.py:326: AssertionError
______________________ TestDundersPartialOrdering.test_ne ______________________

self = <tests.test_cmp.TestDundersPartialOrdering object at 0x7f8f99705010>

    def test_ne(self):
        """
        __ne__ docstring and qualified name should be well behaved.
        """
        method = self.cls.__ne__
>       assert method.__doc__.strip() == (
            "Check equality and either forward a NotImplemented or\n"
            "        return the result negated."
        )
E       AssertionError: assert 'Check equality and either forward a NotImplemented or\nreturn the result negated.' == 'Check equality and either forward a NotImplemented or\n        return the result negated.'
E           Check equality and either forward a NotImplemented or
E         -         return the result negated.
E         ? --------
E         + return the result negated.

tests/test_cmp.py:394: AssertionError
_______________________ TestDundersFullOrdering.test_ne ________________________

self = <tests.test_cmp.TestDundersFullOrdering object at 0x7f8f99704b30>

    def test_ne(self):
        """
        __ne__ docstring and qualified name should be well behaved.
        """
        method = self.cls.__ne__
>       assert method.__doc__.strip() == (
            "Check equality and either forward a NotImplemented or\n"
            "        return the result negated."
        )
E       AssertionError: assert 'Check equality and either forward a NotImplemented or\nreturn the result negated.' == 'Check equality and either forward a NotImplemented or\n        return the result negated.'
E           Check equality and either forward a NotImplemented or
E         -         return the result negated.
E         ? --------
E         + return the result negated.

tests/test_cmp.py:466: AssertionError
webknjaz commented 9 months ago

Action item: make the test conditional with the new behavior checked under Python 3.13+ and the old one checked otherwise.