diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:57:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:57:07 +0000 |
commit | 46fc0a4b3dccce58c429f408c04cf5cda3af9fb5 (patch) | |
tree | 410d83c434319e0c6f8035cdfa60ae8957b1d909 /tests/test_environment | |
parent | Adding upstream version 7.3.7. (diff) | |
download | sphinx-46fc0a4b3dccce58c429f408c04cf5cda3af9fb5.tar.xz sphinx-46fc0a4b3dccce58c429f408c04cf5cda3af9fb5.zip |
Adding upstream version 7.4.7.upstream/7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_environment')
-rw-r--r-- | tests/test_environment/test_environment.py | 2 | ||||
-rw-r--r-- | tests/test_environment/test_environment_indexentries.py | 86 | ||||
-rw-r--r-- | tests/test_environment/test_environment_toctree.py | 37 |
3 files changed, 80 insertions, 45 deletions
diff --git a/tests/test_environment/test_environment.py b/tests/test_environment/test_environment.py index 8a34457..82de597 100644 --- a/tests/test_environment/test_environment.py +++ b/tests/test_environment/test_environment.py @@ -34,7 +34,7 @@ def test_config_status(make_app, app_params): assert app3.env.config_status == CONFIG_CHANGED app3.build() shutil.move(fname[:-4] + 'x.rst', fname) - assert "[config changed ('root_doc')] 1 added" in app3._status.getvalue() + assert "[config changed ('master_doc')] 1 added" in app3._status.getvalue() # incremental build (extension changed) app4 = make_app(*args, confoverrides={'extensions': ['sphinx.ext.autodoc']}, **kwargs) diff --git a/tests/test_environment/test_environment_indexentries.py b/tests/test_environment/test_environment_indexentries.py index 4cfdc28..19cb5a7 100644 --- a/tests/test_environment/test_environment_indexentries.py +++ b/tests/test_environment/test_environment_indexentries.py @@ -22,22 +22,22 @@ def test_create_single_index(app): restructuredtext.parse(app, text) index = IndexEntries(app.env).create_index(app.builder) assert len(index) == 6 - assert index[0] == ('Symbols', [('&-symbol', [[('', '#index-9')], [], None]), - ('9-symbol', [[('', '#index-8')], [], None]), - ('£100', [[('', '#index-10')], [], None])]) - assert index[1] == ('D', [('docutils', [[('', '#index-0')], [], None])]) - assert index[2] == ('P', [('pip', [[], [('install', [('', '#index-2')]), - ('upgrade', [('', '#index-3')])], None]), - ('Python', [[('', '#index-1')], [], None])]) - assert index[3] == ('S', [('Sphinx', [[('', '#index-4')], [], None])]) + assert index[0] == ('Symbols', [('&-symbol', ([('', '#index-9')], [], None)), + ('9-symbol', ([('', '#index-8')], [], None)), + ('£100', ([('', '#index-10')], [], None))]) + assert index[1] == ('D', [('docutils', ([('', '#index-0')], [], None))]) + assert index[2] == ('P', [('pip', ([], [('install', [('', '#index-2')]), + ('upgrade', [('', '#index-3')])], None)), + ('Python', ([('', '#index-1')], [], None))]) + assert index[3] == ('S', [('Sphinx', ([('', '#index-4')], [], None))]) assert index[4] == ('Е', - [('ёлка', [[('', '#index-6')], [], None]), - ('Ель', [[('', '#index-5')], [], None])]) + [('ёлка', ([('', '#index-6')], [], None)), + ('Ель', ([('', '#index-5')], [], None))]) # Here the word starts with U+200F RIGHT-TO-LEFT MARK, which should be # ignored when getting the first letter. assert index[5] == ('\u05e2', [( '\N{RIGHT-TO-LEFT MARK}\u05e2\u05d1\u05e8\u05d9\u05ea\N{LEFT-TO-RIGHT MARK}', - [[('', '#index-7')], [], None], + ([('', '#index-7')], [], None), )]) @@ -52,24 +52,24 @@ def test_create_pair_index(app): restructuredtext.parse(app, text) index = IndexEntries(app.env).create_index(app.builder) assert len(index) == 7 - assert index[0] == ('Symbols', [(':+1:', [[], [('Sphinx', [('', '#index-3')])], None])]) + assert index[0] == ('Symbols', [(':+1:', ([], [('Sphinx', [('', '#index-3')])], None))]) assert index[1] == ('D', - [('documentation tool', [[], [('Sphinx', [('', '#index-2')])], None]), - ('docutils', [[], [('reStructuredText', [('', '#index-0')])], None])]) - assert index[2] == ('I', [('interpreter', [[], [('Python', [('', '#index-1')])], None])]) - assert index[3] == ('P', [('Python', [[], [('interpreter', [('', '#index-1')])], None])]) + [('documentation tool', ([], [('Sphinx', [('', '#index-2')])], None)), + ('docutils', ([], [('reStructuredText', [('', '#index-0')])], None))]) + assert index[2] == ('I', [('interpreter', ([], [('Python', [('', '#index-1')])], None))]) + assert index[3] == ('P', [('Python', ([], [('interpreter', [('', '#index-1')])], None))]) assert index[4] == ('R', - [('reStructuredText', [[], [('docutils', [('', '#index-0')])], None])]) + [('reStructuredText', ([], [('docutils', [('', '#index-0')])], None))]) assert index[5] == ('S', - [('Sphinx', [[], + [('Sphinx', ([], [(':+1:', [('', '#index-3')]), ('documentation tool', [('', '#index-2')]), ('ёлка', [('', '#index-5')]), ('Ель', [('', '#index-4')])], - None])]) + None))]) assert index[6] == ('Е', - [('ёлка', [[], [('Sphinx', [('', '#index-5')])], None]), - ('Ель', [[], [('Sphinx', [('', '#index-4')])], None])]) + [('ёлка', ([], [('Sphinx', [('', '#index-5')])], None)), + ('Ель', ([], [('Sphinx', [('', '#index-4')])], None))]) @pytest.mark.sphinx('dummy', freshenv=True) @@ -79,12 +79,12 @@ def test_create_triple_index(app): restructuredtext.parse(app, text) index = IndexEntries(app.env).create_index(app.builder) assert len(index) == 5 - assert index[0] == ('B', [('bar', [[], [('baz, foo', [('', '#index-0')])], None]), - ('baz', [[], [('foo bar', [('', '#index-0')])], None])]) - assert index[1] == ('F', [('foo', [[], [('bar baz', [('', '#index-0')])], None])]) - assert index[2] == ('P', [('Python', [[], [('Sphinx reST', [('', '#index-1')])], None])]) - assert index[3] == ('R', [('reST', [[], [('Python Sphinx', [('', '#index-1')])], None])]) - assert index[4] == ('S', [('Sphinx', [[], [('reST, Python', [('', '#index-1')])], None])]) + assert index[0] == ('B', [('bar', ([], [('baz, foo', [('', '#index-0')])], None)), + ('baz', ([], [('foo bar', [('', '#index-0')])], None))]) + assert index[1] == ('F', [('foo', ([], [('bar baz', [('', '#index-0')])], None))]) + assert index[2] == ('P', [('Python', ([], [('Sphinx reST', [('', '#index-1')])], None))]) + assert index[3] == ('R', [('reST', ([], [('Python Sphinx', [('', '#index-1')])], None))]) + assert index[4] == ('S', [('Sphinx', ([], [('reST, Python', [('', '#index-1')])], None))]) @pytest.mark.sphinx('dummy', freshenv=True) @@ -95,9 +95,9 @@ def test_create_see_index(app): restructuredtext.parse(app, text) index = IndexEntries(app.env).create_index(app.builder) assert len(index) == 3 - assert index[0] == ('D', [('docutils', [[], [('see reStructuredText', [])], None])]) - assert index[1] == ('P', [('Python', [[], [('see interpreter', [])], None])]) - assert index[2] == ('S', [('Sphinx', [[], [('see documentation tool', [])], None])]) + assert index[0] == ('D', [('docutils', ([], [('see reStructuredText', [])], None))]) + assert index[1] == ('P', [('Python', ([], [('see interpreter', [])], None))]) + assert index[2] == ('S', [('Sphinx', ([], [('see documentation tool', [])], None))]) @pytest.mark.sphinx('dummy', freshenv=True) @@ -108,9 +108,9 @@ def test_create_seealso_index(app): restructuredtext.parse(app, text) index = IndexEntries(app.env).create_index(app.builder) assert len(index) == 3 - assert index[0] == ('D', [('docutils', [[], [('see also reStructuredText', [])], None])]) - assert index[1] == ('P', [('Python', [[], [('see also interpreter', [])], None])]) - assert index[2] == ('S', [('Sphinx', [[], [('see also documentation tool', [])], None])]) + assert index[0] == ('D', [('docutils', ([], [('see also reStructuredText', [])], None))]) + assert index[1] == ('P', [('Python', ([], [('see also interpreter', [])], None))]) + assert index[2] == ('S', [('Sphinx', ([], [('see also documentation tool', [])], None))]) @pytest.mark.sphinx('dummy', freshenv=True) @@ -122,10 +122,10 @@ def test_create_main_index(app): restructuredtext.parse(app, text) index = IndexEntries(app.env).create_index(app.builder) assert len(index) == 2 - assert index[0] == ('D', [('docutils', [[('main', '#index-0'), - ('', '#index-1')], [], None])]) - assert index[1] == ('P', [('pip', [[], [('install', [('main', '#index-3'), - ('', '#index-2')])], None])]) + assert index[0] == ('D', [('docutils', ([('main', '#index-0'), + ('', '#index-1')], [], None))]) + assert index[1] == ('P', [('pip', ([], [('install', [('main', '#index-3'), + ('', '#index-2')])], None))]) @pytest.mark.sphinx('dummy', freshenv=True) @@ -140,9 +140,9 @@ def test_create_index_with_name(app): # check index is created correctly assert len(index) == 3 - assert index[0] == ('D', [('docutils', [[('', '#ref1')], [], None])]) - assert index[1] == ('P', [('Python', [[('', '#ref2')], [], None])]) - assert index[2] == ('S', [('Sphinx', [[('', '#index-0')], [], None])]) + assert index[0] == ('D', [('docutils', ([('', '#ref1')], [], None))]) + assert index[1] == ('P', [('Python', ([('', '#ref2')], [], None))]) + assert index[2] == ('S', [('Sphinx', ([('', '#index-0')], [], None))]) # check the reference labels are created correctly std = app.env.get_domain('std') @@ -161,6 +161,6 @@ def test_create_index_by_key(app): restructuredtext.parse(app, text) index = IndexEntries(app.env).create_index(app.builder) assert len(index) == 3 - assert index[0] == ('D', [('docutils', [[('main', '#term-docutils')], [], None])]) - assert index[1] == ('P', [('Python', [[('main', '#term-Python')], [], None])]) - assert index[2] == ('ス', [('スフィンクス', [[('main', '#term-0')], [], 'ス'])]) + assert index[0] == ('D', [('docutils', ([('main', '#term-docutils')], [], None))]) + assert index[1] == ('P', [('Python', ([('main', '#term-Python')], [], None))]) + assert index[2] == ('ス', [('スフィンクス', ([('main', '#term-0')], [], 'ス'))]) diff --git a/tests/test_environment/test_environment_toctree.py b/tests/test_environment/test_environment_toctree.py index 175c6ab..6979a12 100644 --- a/tests/test_environment/test_environment_toctree.py +++ b/tests/test_environment/test_environment_toctree.py @@ -132,7 +132,7 @@ def test_domain_objects(app): assert app.env.toc_num_entries['index'] == 0 assert app.env.toc_num_entries['domains'] == 9 - assert app.env.toctree_includes['index'] == ['domains'] + assert app.env.toctree_includes['index'] == ['domains', 'document_scoping'] assert 'index' in app.env.files_to_rebuild['domains'] assert app.env.glob_toctrees == set() assert app.env.numbered_toctrees == {'index'} @@ -161,6 +161,41 @@ def test_domain_objects(app): [list_item, ([compact_paragraph, reference, literal, "HelloWorldPrinter.print()"])]) +@pytest.mark.sphinx('dummy', testroot='toctree-domain-objects') +def test_domain_objects_document_scoping(app): + app.build() + + # tocs + toctree = app.env.tocs['document_scoping'] + assert_node( + toctree, + [bullet_list, list_item, ( + compact_paragraph, # [0][0] + [bullet_list, ( # [0][1] + [list_item, compact_paragraph, reference, literal, 'ClassLevel1a'], # [0][1][0] + [list_item, ( # [0][1][1] + [compact_paragraph, reference, literal, 'ClassLevel1b'], # [0][1][1][0] + [bullet_list, list_item, compact_paragraph, reference, literal, 'ClassLevel1b.f()'], # [0][1][1][1][0] + )], + [list_item, compact_paragraph, reference, literal, 'ClassLevel1a.g()'], # [0][1][2] + [list_item, compact_paragraph, reference, literal, 'ClassLevel1b.g()'], # [0][1][3] + [list_item, ( # [0][1][4] + [compact_paragraph, reference, 'Level 2'], # [0][1][4][0] + [bullet_list, ( # [0][1][4][1] + [list_item, compact_paragraph, reference, literal, 'ClassLevel2a'], # [0][1][4][1][0] + [list_item, ( # [0][1][4][1][1] + [compact_paragraph, reference, literal, 'ClassLevel2b'], # [0][1][4][1][1][0] + [bullet_list, list_item, compact_paragraph, reference, literal, 'ClassLevel2b.f()'], # [0][1][4][1][1][1][0] + )], + [list_item, compact_paragraph, reference, literal, 'ClassLevel2a.g()'], # [0][1][4][1][2] + [list_item, compact_paragraph, reference, literal, 'ClassLevel2b.g()'], # [0][1][4][1][3] + )], + )], + )], + )], + ) + + @pytest.mark.sphinx('xml', testroot='toctree') @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_document_toc(app): |