from __future__ import annotations
import pygments
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 (
'
'
) 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):
if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
sp = ' '
else:
sp = ' '
app.build()
content = (app.outdir / 'index.html').read_text(encoding='utf8')
common_content = (
f'def{sp}foo'
'('
'1 '
'+ '
'2 '
'+ '
'None '
'+ '
'"abc"'
'): '
'pass'
)
assert (
'Inline '
+ common_content
+ '
code block
'
) in content
assert (
''
'
' + common_content
) in content