(app: SphinxTestApp)
| 608 | |
| 609 | @pytest.mark.sphinx('dummy', testroot='directive-code') |
| 610 | def 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 |
| 616 | Second line |
| 617 | Third line |
| 618 | Fourth 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…