Skip to content

sphinx fails in the test-suite on machines with too many threads #353176

@Ma27

Description

@Ma27

Describe the bug

python312Packages.sphinx fails in the test-suite like this on a machine with 128 threads:

=================================== FAILURES ===================================
____________________________ test_document_toc_only ____________________________
[gw23] linux -- Python 3.12.7 /nix/store/jmdgllg6l6f1fkndjrj9g40gwyry54wy-python3-3.12.7/bin/python3.12

app = <SphinxTestAppWrapperForSkipBuilding buildername='xml'>

    @pytest.mark.sphinx('xml', testroot='toctree')
    @pytest.mark.test_params(shared_result='test_environment_toctree_basic')
    def test_document_toc_only(app):
        app.build()
        builder = StandaloneHTMLBuilder(app, app.env)
        toctree = document_toc(app.env, 'index', builder.tags)
    
>       assert_node(toctree,
                    [bullet_list, ([list_item, (compact_paragraph,  # [0][0]
                                                [bullet_list, (addnodes.toctree,  # [0][1][0]
                                                               list_item,  # [0][1][1]
                                                               list_item)])],  # [0][1][2]
                                   [list_item, (compact_paragraph,  # [1][0]
                                                [bullet_list, (addnodes.toctree,
                                                               addnodes.toctree)])],
                                   [list_item, compact_paragraph])])  # [2][0]

tests/test_environment/test_environment_toctree.py:231: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
sphinx/testing/util.py:38: in assert_node
    assert_node(node, cls[1], xpath=xpath, **kwargs)
sphinx/testing/util.py:52: in assert_node
    assert_node(node[i], nodecls, xpath=path, **kwargs)
sphinx/testing/util.py:38: in assert_node
    assert_node(node, cls[1], xpath=xpath, **kwargs)
sphinx/testing/util.py:52: in assert_node
    assert_node(node[i], nodecls, xpath=path, **kwargs)
sphinx/testing/util.py:38: in assert_node
    assert_node(node, cls[1], xpath=xpath, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

node = <bullet_list: <toctree...><list_item...>>
cls = (<class 'sphinx.addnodes.toctree'>, <class 'docutils.nodes.list_item'>, <class 'docutils.nodes.list_item'>)
xpath = '[0][1]', kwargs = {}

    def assert_node(node: Node, cls: Any = None, xpath: str = "", **kwargs: Any) -> None:
        if cls:
            if isinstance(cls, list):
                assert_node(node, cls[0], xpath=xpath, **kwargs)
                if cls[1:]:
                    if isinstance(cls[1], tuple):
                        assert_node(node, cls[1], xpath=xpath, **kwargs)
                    else:
                        assert isinstance(node, nodes.Element), \
                            'The node%s does not have any children' % xpath
                        assert len(node) == 1, \
                            'The node%s has %d child nodes, not one' % (xpath, len(node))
                        assert_node(node[0], cls[1:], xpath=xpath + "[0]", **kwargs)
            elif isinstance(cls, tuple):
                assert isinstance(node, (list, nodes.Element)), \
                    'The node%s does not have any items' % xpath
>               assert len(node) == len(cls), \
                    'The node%s has %d child nodes, not %r' % (xpath, len(node), len(cls))
E               AssertionError: The node[0][1] has 2 child nodes, not 3

sphinx/testing/util.py:48: AssertionError

Building on machines with less threads works for me.

Additional context

Last observed on d32fe41.

Notify maintainers

cc @mweinelt (sorry, but you do most of the Python stuff and sphinx doesn't seem to have any maintainers currently 😅 )

Metadata


Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions