import pytest @pytest.mark.sphinx('html', testroot='reST-code-block', confoverrides={'html_codeblock_linenos_style': 'table'}) def test_html_codeblock_linenos_style_table(app): app.build() content = (app.outdir / 'index.html').read_text(encoding='utf8') assert ('
1\n'
            '2\n'
            '3\n'
            '4
') in content @pytest.mark.sphinx('html', testroot='reST-code-block', confoverrides={'html_codeblock_linenos_style': 'inline'}) def test_html_codeblock_linenos_style_inline(app): app.build() content = (app.outdir / 'index.html').read_text(encoding='utf8') assert '1' in content @pytest.mark.sphinx('html', testroot='reST-code-role') def test_html_code_role(app): app.build() content = (app.outdir / 'index.html').read_text(encoding='utf8') common_content = ( 'def foo' '(' '1 ' '+ ' '2 ' '+ ' 'None ' '+ ' '"abc"' '): ' 'pass') assert ('

Inline ' + common_content + ' code block

') in content assert ('
' + '
' +
            common_content) in content