-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Docstring of __weakref__ in Python has changed - test_autodoc_default_options and test_autodoc_default_options_with_values rely on that #11775
Copy link
Copy link
Closed
Labels
Description
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
Reactions are currently unavailable