本文整理汇总了Python中sphinx.testing.util.assert_node函数的典型用法代码示例。如果您正苦于以下问题:Python assert_node函数的具体用法?Python assert_node怎么用?Python assert_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_node函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_toctree_twice
def test_toctree_twice(app):
text = (".. toctree::\n"
"\n"
" foo\n"
" foo\n")
app.env.find_files(app.config, app.builder)
doctree = parse(app, 'index', text)
assert_node(doctree, [nodes.document, nodes.compound, addnodes.toctree])
assert_node(doctree[0][0],
entries=[(None, 'foo'), (None, 'foo')],
includefiles=['foo', 'foo'])
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:12,代码来源:test_directive_other.py
示例2: test_toctree_glob_and_url
def test_toctree_glob_and_url(app):
text = (".. toctree::\n"
" :glob:\n"
"\n"
" https://example.com/?q=sphinx\n")
app.env.find_files(app.config, app.builder)
doctree = parse(app, 'index', text)
assert_node(doctree, [nodes.document, nodes.compound, addnodes.toctree])
assert_node(doctree[0][0],
entries=[(None, 'https://example.com/?q=sphinx')],
includefiles=[])
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:12,代码来源:test_directive_other.py
示例3: assert_refnode
def assert_refnode(node, module_name, class_name, target, reftype=None,
domain='py'):
attributes = {
'refdomain': domain,
'reftarget': target,
}
if reftype is not None:
attributes['reftype'] = reftype
if module_name is not False:
attributes['py:module'] = module_name
if class_name is not False:
attributes['py:class'] = class_name
assert_node(node, **attributes)
开发者ID:hagenw,项目名称:sphinx,代码行数:13,代码来源:test_domain_py.py
示例4: assert_refnode
def assert_refnode(node, mod_name, prefix, target, reftype=None,
domain='js'):
attributes = {
'refdomain': domain,
'reftarget': target,
}
if reftype is not None:
attributes['reftype'] = reftype
if mod_name is not False:
attributes['js:module'] = mod_name
if prefix is not False:
attributes['js:object'] = prefix
assert_node(node, **attributes)
开发者ID:LFYG,项目名称:sphinx,代码行数:13,代码来源:test_domain_js.py
示例5: test_toctree_urls_and_titles
def test_toctree_urls_and_titles(app):
text = (".. toctree::\n"
"\n"
" Sphinx <https://www.sphinx-doc.org/>\n"
" https://readthedocs.org/\n"
" The BAR <bar/index>\n")
app.env.find_files(app.config, app.builder)
doctree = parse(app, 'index', text)
assert_node(doctree, [nodes.document, nodes.compound, addnodes.toctree])
assert_node(doctree[0][0],
entries=[('Sphinx', 'https://www.sphinx-doc.org/'),
(None, 'https://readthedocs.org/'),
('The BAR', 'bar/index')],
includefiles=['bar/index'])
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:15,代码来源:test_directive_other.py
示例6: test_relative_toctree
def test_relative_toctree(app):
text = (".. toctree::\n"
"\n"
" bar_1\n"
" bar_2\n"
" bar_3\n"
" ../quux\n")
app.env.find_files(app.config, app.builder)
doctree = parse(app, 'bar/index', text)
assert_node(doctree, [nodes.document, nodes.compound, addnodes.toctree])
assert_node(doctree[0][0],
entries=[(None, 'bar/bar_1'), (None, 'bar/bar_2'), (None, 'bar/bar_3'),
(None, 'quux')],
includefiles=['bar/bar_1', 'bar/bar_2', 'bar/bar_3', 'quux'])
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:15,代码来源:test_directive_other.py
示例7: test_compact_refonly_bullet_list
def test_compact_refonly_bullet_list(app, status, warning):
app.builder.build_all()
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
assert_node(doctree[0], nodes.section)
assert len(doctree[0]) == 5
assert doctree[0][1].astext() == 'List A:'
assert_node(doctree[0][2], nodes.bullet_list)
assert_node(doctree[0][2][0][0], addnodes.compact_paragraph)
assert doctree[0][2][0][0].astext() == 'genindex'
assert doctree[0][3].astext() == 'List B:'
assert_node(doctree[0][4], nodes.bullet_list)
assert_node(doctree[0][4][0][0], nodes.paragraph)
assert doctree[0][4][0][0].astext() == 'Hello'
开发者ID:atodorov,项目名称:sphinx,代码行数:15,代码来源:test_markup.py
示例8: test_get_toc_for
def test_get_toc_for(app):
app.build()
toctree = TocTree(app.env).get_toc_for('index', app.builder)
assert_node(toctree,
[bullet_list, ([list_item, (compact_paragraph, # [0][0]
[bullet_list, (addnodes.toctree, # [0][1][0]
comment, # [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]
assert_node(toctree[0][0],
[compact_paragraph, reference, u"Welcome to Sphinx Tests’s documentation!"])
assert_node(toctree[0][1][2],
([compact_paragraph, reference, "subsection"],
[bullet_list, list_item, compact_paragraph, reference, "subsubsection"]))
assert_node(toctree[1][0],
[compact_paragraph, reference, "Test for issue #1157"])
assert_node(toctree[2][0],
[compact_paragraph, reference, "Indices and tables"])
开发者ID:AWhetter,项目名称:sphinx,代码行数:22,代码来源:test_environment_toctree.py
示例9: test_get_toc_for_tocdepth
def test_get_toc_for_tocdepth(app):
app.build()
toctree = TocTree(app.env).get_toc_for('tocdepth', app.builder)
assert_node(toctree,
[bullet_list, list_item, (compact_paragraph, # [0][0]
bullet_list)]) # [0][1]
assert_node(toctree[0][0],
[compact_paragraph, reference, "level 1"])
assert_node(toctree[0][1],
[bullet_list, list_item, compact_paragraph, reference, "level 2"])
开发者ID:AWhetter,项目名称:sphinx,代码行数:11,代码来源:test_environment_toctree.py
示例10: test_math_compat
def test_math_compat(app, status, warning):
with warnings.catch_warnings(record=True):
app.builder.build_all()
doctree = app.env.get_and_resolve_doctree('index', app.builder)
assert_node(doctree,
[nodes.document, nodes.section, (nodes.title,
[nodes.section, (nodes.title,
nodes.paragraph)],
nodes.section)])
assert_node(doctree[0][1][1],
('Inline: ',
[nodes.math, "E=mc^2"],
'\nInline my math: ',
[nodes.math, "E = mc^2"]))
assert_node(doctree[0][2],
([nodes.title, "block"],
[nodes.math_block, "a^2+b^2=c^2\n\n"],
[nodes.paragraph, "Second math"],
[nodes.math_block, "e^{i\\pi}+1=0\n\n"],
[nodes.paragraph, "Multi math equations"],
[nodes.math_block, "E = mc^2"]))
开发者ID:mgeier,项目名称:sphinx,代码行数:22,代码来源:test_ext_math.py
示例11: test_keep_warnings_is_False
def test_keep_warnings_is_False(app, status, warning):
app.builder.build_all()
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
assert_node(doctree[0], nodes.section)
assert len(doctree[0]) == 1
开发者ID:atodorov,项目名称:sphinx,代码行数:5,代码来源:test_markup.py
示例12: test_rst_prolog
def test_rst_prolog(app, status, warning):
app.builder.build_all()
rst = pickle.loads((app.doctreedir / 'restructuredtext.doctree').bytes())
md = pickle.loads((app.doctreedir / 'markdown.doctree').bytes())
# rst_prolog
assert_node(rst[0], nodes.paragraph)
assert_node(rst[0][0], nodes.emphasis)
assert_node(rst[0][0][0], nodes.Text)
assert rst[0][0][0] == 'Hello world'
# rst_epilog
assert_node(rst[-1], nodes.section)
assert_node(rst[-1][-1], nodes.paragraph)
assert_node(rst[-1][-1][0], nodes.emphasis)
assert_node(rst[-1][-1][0][0], nodes.Text)
assert rst[-1][-1][0][0] == 'Good-bye world'
# rst_prolog & rst_epilog on exlucding reST parser
assert not md.rawsource.startswith('*Hello world*.')
assert not md.rawsource.endswith('*Good-bye world*.\n')
开发者ID:atodorov,项目名称:sphinx,代码行数:21,代码来源:test_markup.py
示例13: test_samp
def test_samp():
# normal case
text = 'print 1+{variable}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, ("print 1+",
[nodes.emphasis, "variable"])],))
assert msg == []
# two emphasis items
text = 'print {1}+{variable}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, ("print ",
[nodes.emphasis, "1"],
"+",
[nodes.emphasis, "variable"])],))
assert msg == []
# empty curly brace
text = 'print 1+{}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, "print 1+{}"],))
assert msg == []
# half-opened variable
text = 'print 1+{variable'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, "print 1+{variable"],))
assert msg == []
# nested
text = 'print 1+{{variable}}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, ("print 1+",
[nodes.emphasis, "{variable"],
"}")],))
assert msg == []
# emphasized item only
text = '{variable}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, nodes.emphasis, "variable"],))
assert msg == []
# escaping
text = r'print 1+\{variable}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, "print 1+{variable}"],))
assert msg == []
# escaping (2)
text = r'print 1+\{{variable}\}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, ("print 1+{",
[nodes.emphasis, "variable"],
"}")],))
assert msg == []
# escape a backslash
text = r'print 1+\\{variable}'
ret, msg = emph_literal_role('samp', text, text, 0, Mock())
assert_node(ret, ([nodes.literal, ("print 1+\\",
[nodes.emphasis, "variable"])],))
assert msg == []
开发者ID:mgeier,项目名称:sphinx,代码行数:63,代码来源:test_roles.py
示例14: test_image_glob_intl_using_figure_language_filename
def test_image_glob_intl_using_figure_language_filename(app):
app.build()
# index.rst
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
assert_node(doctree[0][1], nodes.image, uri='rimg.png.xx',
candidates={'*': 'rimg.png.xx'})
assert isinstance(doctree[0][2], nodes.figure)
assert_node(doctree[0][2][0], nodes.image, uri='rimg.png.xx',
candidates={'*': 'rimg.png.xx'})
assert_node(doctree[0][3], nodes.image, uri='img.*',
candidates={'application/pdf': 'img.pdf',
'image/gif': 'img.gif',
'image/png': 'img.png'})
assert isinstance(doctree[0][4], nodes.figure)
assert_node(doctree[0][4][0], nodes.image, uri='img.*',
candidates={'application/pdf': 'img.pdf',
'image/gif': 'img.gif',
'image/png': 'img.png'})
# subdir/index.rst
doctree = pickle.loads((app.doctreedir / 'subdir/index.doctree').bytes())
assert_node(doctree[0][1], nodes.image, uri='subdir/rimg.png',
candidates={'*': 'subdir/rimg.png'})
assert_node(doctree[0][2], nodes.image, uri='subdir/svgimg.*',
candidates={'application/pdf': 'subdir/svgimg.pdf',
'image/svg+xml': 'subdir/svgimg.svg'})
assert isinstance(doctree[0][3], nodes.figure)
assert_node(doctree[0][3][0], nodes.image, uri='subdir/svgimg.*',
candidates={'application/pdf': 'subdir/svgimg.pdf',
'image/svg+xml': 'subdir/svgimg.svg'})
开发者ID:sam-m888,项目名称:sphinx,代码行数:37,代码来源:test_intl.py
示例15: test_default_role2
def test_default_role2(app, status, warning):
app.builder.build_all()
# default-role directive is stronger than configratuion
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
assert_node(doctree[0], nodes.section)
assert_node(doctree[0][1], nodes.paragraph)
assert_node(doctree[0][1][0], addnodes.index)
assert_node(doctree[0][1][1], nodes.target)
assert_node(doctree[0][1][2], nodes.reference, classes=["pep"])
# default_role changes the default behavior
doctree = pickle.loads((app.doctreedir / 'foo.doctree').bytes())
assert_node(doctree[0], nodes.section)
assert_node(doctree[0][1], nodes.paragraph)
assert_node(doctree[0][1][0], nodes.inline, classes=["guilabel"])
assert_node(doctree[0][1][1], nodes.Text)
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:17,代码来源:test_markup.py
示例16: test_default_role1
def test_default_role1(app, status, warning):
app.builder.build_all()
# default-role: pep
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
assert_node(doctree[0], nodes.section)
assert_node(doctree[0][1], nodes.paragraph)
assert_node(doctree[0][1][0], addnodes.index)
assert_node(doctree[0][1][1], nodes.target)
assert_node(doctree[0][1][2], nodes.reference, classes=["pep"])
# no default-role
doctree = pickle.loads((app.doctreedir / 'foo.doctree').bytes())
assert_node(doctree[0], nodes.section)
assert_node(doctree[0][1], nodes.paragraph)
assert_node(doctree[0][1][0], nodes.title_reference)
assert_node(doctree[0][1][1], nodes.Text)
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:17,代码来源:test_markup.py
示例17: test_glob
def test_glob(app):
includefiles = ['foo', 'bar/index', 'bar/bar_1', 'bar/bar_2',
'bar/bar_3', 'baz', 'qux/index']
app.build()
# tocs
toctree = app.env.tocs['index']
assert_node(toctree,
[bullet_list, list_item, (compact_paragraph, # [0][0]
[bullet_list, (list_item, # [0][1][0]
list_item)])]) # [0][1][1]
assert_node(toctree[0][0],
[compact_paragraph, reference, "test-toctree-glob"])
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,
maxdepth=-1, numbered=0, includefiles=includefiles,
entries=[(None, 'foo'), (None, 'bar/index'), (None, 'bar/bar_1'),
(None, 'bar/bar_2'), (None, 'bar/bar_3'), (None, 'baz'),
(None, 'qux/index'), ('hyperref', 'https://sphinx-doc.org/?q=sphinx')])
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
assert app.env.toc_num_entries['index'] == 3
assert app.env.toctree_includes['index'] == includefiles + includefiles
for file in includefiles:
assert 'index' in app.env.files_to_rebuild[file]
assert 'index' in app.env.glob_toctrees
assert app.env.numbered_toctrees == set()
开发者ID:AWhetter,项目名称:sphinx,代码行数:43,代码来源:test_environment_toctree.py
示例18: test_get_toctree_for_includehidden
def test_get_toctree_for_includehidden(app):
app.build()
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False,
includehidden=False)
assert_node(toctree,
[compact_paragraph, ([caption, "Table of Contents"],
bullet_list,
bullet_list)])
assert_node(toctree[1],
([list_item, ([compact_paragraph, reference, "foo"],
bullet_list)],
[list_item, compact_paragraph, reference, "bar"],
[list_item, compact_paragraph, reference, "http://sphinx-doc.org/"]))
assert_node(toctree[1][0][1],
([list_item, compact_paragraph, reference, "quux"],
[list_item, compact_paragraph, reference, "foo.1"],
[list_item, compact_paragraph, reference, "foo.2"]))
assert_node(toctree[1][0][0][0], reference, refuri="foo", secnumber=(1,))
assert_node(toctree[1][0][1][0][0][0], reference, refuri="quux", secnumber=(1, 1))
assert_node(toctree[1][0][1][1][0][0], reference, refuri="foo#foo-1", secnumber=(1, 2))
assert_node(toctree[1][0][1][2][0][0], reference, refuri="foo#foo-2", secnumber=(1, 3))
assert_node(toctree[1][1][0][0], reference, refuri="bar", secnumber=(2,))
assert_node(toctree[1][2][0][0], reference, refuri="http://sphinx-doc.org/")
assert_node(toctree[2],
[bullet_list, list_item, compact_paragraph, reference, "baz"])
开发者ID:AWhetter,项目名称:sphinx,代码行数:28,代码来源:test_environment_toctree.py
示例19: test_get_toctree_for_collapse
def test_get_toctree_for_collapse(app):
app.build()
toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=True)
assert_node(toctree,
[compact_paragraph, ([caption, "Table of Contents"],
bullet_list,
bullet_list,
bullet_list)])
assert_node(toctree[1],
([list_item, compact_paragraph, reference, "foo"],
[list_item, compact_paragraph, reference, "bar"],
[list_item, compact_paragraph, reference, "http://sphinx-doc.org/"]))
assert_node(toctree[1][0][0][0], reference, refuri="foo", secnumber=(1,))
assert_node(toctree[1][1][0][0], reference, refuri="bar", secnumber=(2,))
assert_node(toctree[1][2][0][0], reference, refuri="http://sphinx-doc.org/")
assert_node(toctree[2],
[bullet_list, list_item, compact_paragraph, reference, "baz"])
assert_node(toctree[3],
([list_item, compact_paragraph, reference, "Latest reference"],
[list_item, compact_paragraph, reference, "Python"]))
assert_node(toctree[3][0][0][0], reference, refuri="http://sphinx-doc.org/latest/")
assert_node(toctree[3][1][0][0], reference, refuri="http://python.org/")
开发者ID:AWhetter,项目名称:sphinx,代码行数:24,代码来源:test_environment_toctree.py
示例20: test_process_doc
def test_process_doc(app):
app.build()
# tocs
toctree = app.env.tocs['index']
assert_node(toctree,
[bullet_list, ([list_item, (compact_paragraph, # [0][0]
[bullet_list, (addnodes.toctree, # [0][1][0]
only, # [0][1][1]
list_item)])], # [0][1][2]
[list_item, (compact_paragraph, # [1][0]
[bullet_list, (addnodes.toctree, # [1][1][0]
addnodes.toctree)])], # [1][1][1]
list_item)])
assert_node(toctree[0][0],
[compact_paragraph, reference, u"Welcome to Sphinx Tests’s documentation!"])
assert_node(toctree[0][0][0], reference, anchorname='')
assert_node(toctree[0][1][0], addnodes.toctree,
caption="Table of Contents", glob=False, hidden=False,
titlesonly=False, maxdepth=2, numbered=999,
entries=[(None, 'foo'), (None, 'bar'), (None, 'http://sphinx-doc.org/')],
includefiles=['foo', 'bar'])
# only branch
assert_node(toctree[0][1][1], addnodes.only, expr="html")
assert_node(toctree[0][1][1],
[only, list_item, ([compact_paragraph, reference, "Section for HTML"],
[bullet_list, addnodes.toctree])])
assert_node(toctree[0][1][1][0][0][0], reference, anchorname='#section-for-html')
assert_node(toctree[0][1][1][0][1][0], addnodes.toctree,
caption=None, glob=False, hidden=False, entries=[(None, 'baz')],
includefiles=['baz'], titlesonly=False, maxdepth=-1, numbered=0)
assert_node(toctree[0][1][2],
([compact_paragraph, reference, "subsection"],
[bullet_list, list_item, compact_paragraph, reference, "subsubsection"]))
assert_node(toctree[1][0],
[compact_paragraph, reference, "Test for issue #1157"])
assert_node(toctree[1][0][0], reference, anchorname='#test-for-issue-1157')
assert_node(toctree[1][1][0], addnodes.toctree,
caption=None, entries=[], glob=False, hidden=False,
titlesonly=False, maxdepth=-1, numbered=0)
assert_node(toctree[1][1][1], addnodes.toctree,
caption=None, glob=False, hidden=True,
titlesonly=False, maxdepth=-1, numbered=0,
entries=[('Latest reference', 'http://sphinx-doc.org/latest/'),
('Python', 'http://python.org/')])
assert_node(toctree[2][0],
[compact_paragraph, reference, "Indices and tables"])
# other collections
assert app.env.toc_num_entries['index'] == 6
assert app.env.toctree_includes['index'] == ['foo', 'bar', 'baz']
assert app.env.files_to_rebuild['foo'] == set(['index'])
assert app.env.files_to_rebuild['bar'] == set(['index'])
assert app.env.files_to_rebuild['baz'] == set(['index'])
assert app.env.glob_toctrees == set()
assert app.env.numbered_toctrees == set(['index'])
# qux has no section title
assert len(app.env.tocs['qux']) == 0
assert_node(app.env.tocs['qux'], nodes.bullet_list)
assert app.env.toc_num_entries['qux'] == 0
assert 'qux' not in app.env.toctree_includes
开发者ID:AWhetter,项目名称:sphinx,代码行数:65,代码来源:test_environment_toctree.py
注:本文中的sphinx.testing.util.assert_node函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论