MCPcopy
hub / github.com/sphinx-doc/sphinx / test_code_block_dedent

Function test_code_block_dedent

tests/test_directives/test_directive_code.py:610–633  ·  view source on GitHub ↗
(app: SphinxTestApp)

Source from the content-addressed store, hash-verified

608
609@pytest.mark.sphinx('dummy', testroot='directive-code')
610def test_code_block_dedent(app: SphinxTestApp) -> None:
611 app.build(filenames=[app.srcdir / 'dedent.rst'])
612 doctree = app.env.get_doctree('dedent')
613 codeblocks = list(doctree.findall(nodes.literal_block))
614 # Note: comparison string should not have newlines at the beginning or end
615 text_0_indent = """First line
616Second line
617 Third line
618Fourth line"""
619 text_2_indent = """ First line
620 Second line
621 Third line
622 Fourth line"""
623 text_4_indent = """ First line
624 Second line
625 Third line
626 Fourth line"""
627
628 assert codeblocks[0].astext() == text_0_indent
629 assert codeblocks[1].astext() == text_0_indent
630 assert codeblocks[2].astext() == text_4_indent
631 assert codeblocks[3].astext() == text_2_indent
632 assert codeblocks[4].astext() == text_4_indent
633 assert codeblocks[5].astext() == text_0_indent

Callers

nothing calls this directly

Calls 4

get_doctreeMethod · 0.80
buildMethod · 0.45
findallMethod · 0.45
astextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…