mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-04 18:33:32 -05:00
Add tests for :dedent: option of code-block directive
This commit is contained in:
@@ -580,3 +580,29 @@ def test_linenothreshold(app, status, warning):
|
||||
# literal include not using linenothreshold (no line numbers)
|
||||
assert ('<span></span><span class="c1"># Very small literal include '
|
||||
'(linenothreshold check)</span>' in html)
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='directive-code')
|
||||
def test_code_block_dedent(app, status, warning):
|
||||
app.builder.build(['dedent'])
|
||||
doctree = app.env.get_doctree('dedent')
|
||||
codeblocks = list(doctree.traverse(nodes.literal_block))
|
||||
# Note: comparison string should not have newlines at the beginning or end
|
||||
text_0_indent = '''First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line'''
|
||||
text_2_indent = ''' First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line'''
|
||||
text_4_indent = ''' First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line'''
|
||||
|
||||
assert codeblocks[0].astext() == text_0_indent
|
||||
assert codeblocks[1].astext() == text_0_indent
|
||||
assert codeblocks[2].astext() == text_4_indent
|
||||
assert codeblocks[3].astext() == text_2_indent
|
||||
assert codeblocks[4].astext() == text_4_indent
|
||||
assert codeblocks[5].astext() == text_0_indent
|
||||
|
||||
Reference in New Issue
Block a user