Fix #5770: doctest: Follow highlight_language on highlighting doctest block

This commit is contained in:
Takeshi KOMIYA
2018-12-15 18:35:12 +09:00
parent aaf0046f44
commit d6d4406ce9
3 changed files with 28 additions and 2 deletions

View File

@@ -11,6 +11,7 @@
import os
from collections import Counter
from docutils import nodes
import pytest
from packaging.specifiers import InvalidSpecifier
from packaging.version import InvalidVersion
@@ -32,6 +33,23 @@ def test_build(app, status, warning):
assert cleanup_called == 3, 'testcleanup did not get executed enough times'
@pytest.mark.sphinx('dummy', testroot='ext-doctest')
def test_highlight_language_default(app, status, warning):
app.build()
doctree = app.env.get_doctree('doctest')
for node in doctree.traverse(nodes.literal_block):
assert node['language'] in ('python3', 'pycon3', 'none')
@pytest.mark.sphinx('dummy', testroot='ext-doctest',
confoverrides={'highlight_language': 'python'})
def test_highlight_language_python2(app, status, warning):
app.build()
doctree = app.env.get_doctree('doctest')
for node in doctree.traverse(nodes.literal_block):
assert node['language'] in ('python', 'pycon', 'none')
def test_is_allowed_version():
assert is_allowed_version('<3.4', '3.3') is True
assert is_allowed_version('<3.4', '3.3') is True