当前位置: 首页>>代码示例>>Python>>正文


Python util.assert_node函数代码示例

本文整理汇总了Python中sphinx.testing.util.assert_node函数的典型用法代码示例。如果您正苦于以下问题:Python assert_node函数的具体用法?Python assert_node怎么用?Python assert_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的sphinx.testing.util.assert_node函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。