mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5770: doctest: Follow highlight_language on highlighting doctest block
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user