Add testcase for reversed toctree

This commit is contained in:
Takeshi KOMIYA 2016-10-12 19:32:48 +09:00
parent 8481ed3560
commit f22bbf668d
2 changed files with 35 additions and 4 deletions

View File

@ -1,6 +1,9 @@
test-toctree-glob test-toctree-glob
================= =================
normal order
------------
.. toctree:: .. toctree::
:glob: :glob:
@ -9,3 +12,16 @@ test-toctree-glob
bar/* bar/*
baz baz
qux/index qux/index
reversed order
-------------
.. toctree::
:glob:
:reverse:
foo
bar/index
bar/*
baz
qux/index

View File

@ -108,20 +108,35 @@ def test_glob(app, status, warning):
toctree = app.env.tocs['index'] toctree = app.env.tocs['index']
assert_node(toctree, assert_node(toctree,
[bullet_list, list_item, (compact_paragraph, # [0][0] [bullet_list, list_item, (compact_paragraph, # [0][0]
[bullet_list, addnodes.toctree])]) # [0][1][0] [bullet_list, (list_item, # [0][1][0]
list_item)])]) # [0][1][1]
assert_node(toctree[0][0], assert_node(toctree[0][0],
[compact_paragraph, reference, "test-toctree-glob"]) [compact_paragraph, reference, "test-toctree-glob"])
assert_node(toctree[0][1][0], addnodes.toctree, caption=None, assert_node(toctree[0][1][0],
[list_item, ([compact_paragraph, reference, "normal order"],
[bullet_list, addnodes.toctree])]) # [0][1][0][1][0]
assert_node(toctree[0][1][0][1][0], addnodes.toctree, caption=None,
glob=True, hidden=False, titlesonly=False, glob=True, hidden=False, titlesonly=False,
maxdepth=-1, numbered=0, includefiles=includefiles, maxdepth=-1, numbered=0, includefiles=includefiles,
entries=[(None, 'foo'), (None, 'bar/index'), (None, 'bar/bar_1'), entries=[(None, 'foo'), (None, 'bar/index'), (None, 'bar/bar_1'),
(None, 'bar/bar_2'), (None, 'bar/bar_3'), (None, 'baz'), (None, 'bar/bar_2'), (None, 'bar/bar_3'), (None, 'baz'),
(None, 'qux/index')]) (None, 'qux/index')])
assert_node(toctree[0][1][1],
[list_item, ([compact_paragraph, reference, "reversed order"],
[bullet_list, addnodes.toctree])]) # [0][1][1][1][0]
assert_node(toctree[0][1][1][1][0], addnodes.toctree, caption=None,
glob=True, hidden=False, titlesonly=False,
maxdepth=-1, numbered=0, includefiles=includefiles,
entries=[(None, 'qux/index'), (None, 'baz'), (None, 'bar/bar_3'),
(None, 'bar/bar_2'), (None, 'bar/bar_1'), (None, 'bar/index'),
(None, 'foo')])
includefiles = ['foo', 'bar/index', 'bar/bar_1', 'bar/bar_2',
'bar/bar_3', 'baz', 'qux/index']
# other collections # other collections
assert app.env.toc_num_entries['index'] == 1 assert app.env.toc_num_entries['index'] == 3
assert app.env.toctree_includes['index'] == includefiles assert app.env.toctree_includes['index'] == includefiles + includefiles
for file in includefiles: for file in includefiles:
assert 'index' in app.env.files_to_rebuild[file] assert 'index' in app.env.files_to_rebuild[file]
assert 'index' in app.env.glob_toctrees assert 'index' in app.env.glob_toctrees