Skip to content

Docstring of __weakref__ in Python has changed - test_autodoc_default_options and test_autodoc_default_options_with_values rely on that #11775

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
befeleme opened this issue Nov 28, 2023 · 1 comment

Comments

@befeleme
Copy link
Contributor

Describe the bug

Sphinx 7.2.6 test_autodoc_default_options fails with Python 3.13.0~a2. The change was backported to Python 3.12 and Python 3.11 branches: python/cpython#112266, so it'll be soon in all three Pythons.
I attempted to fix the test lured by the obviousness of the failure but realised that it's not so easy given version matrix (#11774).

=================================== FAILURES ===================================
_________________________ test_autodoc_default_options _________________________

app = <SphinxTestApp buildername='html'>

    @pytest.mark.sphinx('html', testroot='ext-autodoc')
    def test_autodoc_default_options(app):
        # no settings
        actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
        assert '   .. py:attribute:: EnumCls.val1' not in actual
        assert '   .. py:attribute:: EnumCls.val4' not in actual
        actual = do_autodoc(app, 'class', 'target.CustomIter')
        assert '   .. py:method:: target.CustomIter' not in actual
        actual = do_autodoc(app, 'module', 'target')
        assert '.. py:function:: function_to_be_imported(app)' not in actual
    
        # with :members:
        app.config.autodoc_default_options = {'members': None}
        actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
        assert '   .. py:attribute:: EnumCls.val1' in actual
        assert '   .. py:attribute:: EnumCls.val4' not in actual
    
        # with :members: = True
        app.config.autodoc_default_options = {'members': None}
        actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
        assert '   .. py:attribute:: EnumCls.val1' in actual
        assert '   .. py:attribute:: EnumCls.val4' not in actual
    
        # with :members: and :undoc-members:
        app.config.autodoc_default_options = {
            'members': None,
            'undoc-members': None,
        }
        actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
        assert '   .. py:attribute:: EnumCls.val1' in actual
        assert '   .. py:attribute:: EnumCls.val4' in actual
    
        # with :special-members:
        # Note that :members: must be *on* for :special-members: to work.
        app.config.autodoc_default_options = {
            'members': None,
            'special-members': None,
        }
        actual = do_autodoc(app, 'class', 'target.CustomIter')
        assert '   .. py:method:: CustomIter.__init__()' in actual
        assert '      Create a new `CustomIter`.' in actual
        assert '   .. py:method:: CustomIter.__iter__()' in actual
        assert '      Iterate squares of each value.' in actual
        if not IS_PYPY:
            assert '   .. py:attribute:: CustomIter.__weakref__' in actual
>           assert '      list of weak references to the object (if defined)' in actual
E           AssertionError: assert '      list of weak references to the object (if defined)' in StringList(['', '.. py:class:: CustomIter()', '   :module: target', '', '', '   .. py:method:: CustomIter.__init__()',... 0), ('/tmp/pytest-of-mockbuild/pytest-0/ext-autodoc/target/__init__.py:docstring of target.CustomIter.snafucate', 1)])

tests/test_ext_autodoc_configs.py:1630: AssertionError

How to Reproduce

Run tests with Python 3.13.0~a2

Environment Information

Sphinx 7.2.6

Sphinx extensions

No response

Additional context

No response

@picnixz
Copy link
Member

picnixz commented Dec 24, 2023

I am aware of this issue and its corresponding PR. It will probably be the first PR to be merged when we'll resume active development since it blocks the CI

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants