Skip to content

Python 3.13: Two tests from test_docstring.py are failing #1071

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

Closed
penguinpee opened this issue Mar 27, 2024 · 2 comments · Fixed by #1073
Closed

Python 3.13: Two tests from test_docstring.py are failing #1071

penguinpee opened this issue Mar 27, 2024 · 2 comments · Fixed by #1073

Comments

@penguinpee
Copy link

Fedora is preparing for Python 3.13. Two tests are currently failing when imbalanced-learn is built with Python 3.13.0a5. Python is being updated as new pre-releases become available and packages are re-tested.

Error log:

=================================== FAILURES ===================================
_ test_docstring_inject[func-A function.\n\n    Parameters\n    ----------\n    xxx\n\n    yyy\n    ] _

obj = <function func at 0x7f092abffce0>
obj_docstring = 'A function.\n\n    Parameters\n    ----------\n    xxx\n\n    yyy\n    '

    @pytest.mark.parametrize(
        "obj, obj_docstring", [(func, func_docstring), (cls, cls_docstring)]
    )
    def test_docstring_inject(obj, obj_docstring):
        obj_injected_docstring = Substitution(param_1="xxx", param_2="yyy")(obj)
>       assert obj_injected_docstring.__doc__ == obj_docstring
E       AssertionError: assert 'A function.\n\nParameters\n----------\nxxx\n\nyyy\n' == 'A function.\n\n    Parameters\n    ----------\n    xxx\n\n    yyy\n    '
E           A function.
E           
E         -     Parameters
E         ? ----
E         + Parameters
E         -     ----------
E         ? ----
E         + ----------
E         -     xxx
E         + xxx
E           
E         + yyy
E         -     yyy
E         -

imblearn/utils/tests/test_docstring.py:63: AssertionError
_ test_docstring_inject[cls-A class.\n\n    Parameters\n    ----------\n    xxx\n\n    yyy\n    ] _

obj = <class 'imblearn.utils.tests.test_docstring.cls'>
obj_docstring = 'A class.\n\n    Parameters\n    ----------\n    xxx\n\n    yyy\n    '

    @pytest.mark.parametrize(
        "obj, obj_docstring", [(func, func_docstring), (cls, cls_docstring)]
    )
    def test_docstring_inject(obj, obj_docstring):
        obj_injected_docstring = Substitution(param_1="xxx", param_2="yyy")(obj)
>       assert obj_injected_docstring.__doc__ == obj_docstring
E       AssertionError: assert 'A class.\n\nParameters\n----------\nxxx\n\nyyy\n' == 'A class.\n\n    Parameters\n    ----------\n    xxx\n\n    yyy\n    '
E           A class.
E           
E         -     Parameters
E         ? ----
E         + Parameters
E         -     ----------
E         ? ----
E         + ----------
E         -     xxx
E         + xxx
E           
E         + yyy
E         -     yyy
E         -

imblearn/utils/tests/test_docstring.py:63: AssertionError
@penguinpee
Copy link
Author

This is most likely due to:

Compiler now strip indents from docstrings. This will reduce the size of bytecode cache (e.g. .pyc file). For example, cache file size for sqlalchemy.orm.session in SQLAlchemy 2.0 is reduced by about 5%. This change will affect tools using docstrings, like doctest. (Contributed by Inada Naoki in gh-81283.)

as documented in the release notes.

@glemaitre
Copy link
Member

Thanks. We probably want to have our tests insensitive to this particular behaviour. I'll make a fix for that.

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.

2 participants