mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Replace distutils.versions.LooseVersion by packaging.version.Version
Distutils module are now deprecated and will be removed in Python 3.12. This replaces it by packaging module and reduces the dependency to it. refs: #9820
This commit is contained in:
@@ -10,13 +10,13 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
from distutils.version import LooseVersion
|
||||
from itertools import chain, cycle
|
||||
from unittest.mock import ANY, call, patch
|
||||
|
||||
import pygments
|
||||
import pytest
|
||||
from html5lib import HTMLParser
|
||||
from packaging import version
|
||||
|
||||
from sphinx.builders.html import validate_html_extra_path, validate_html_static_path
|
||||
from sphinx.errors import ConfigError
|
||||
@@ -30,6 +30,9 @@ else:
|
||||
FIGURE_CAPTION = ".//figure/figcaption/p"
|
||||
|
||||
|
||||
PYGMENTS_VERSION = version.parse(pygments.__version__).release
|
||||
|
||||
|
||||
ENV_WARNINGS = """\
|
||||
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
|
||||
WARNING: Explicit markup ends without a blank line; unexpected unindent.
|
||||
@@ -1576,8 +1579,7 @@ def test_html_codeblock_linenos_style_table(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
|
||||
pygments_version = tuple(LooseVersion(pygments.__version__).version)
|
||||
if pygments_version >= (2, 8):
|
||||
if PYGMENTS_VERSION >= (2, 8):
|
||||
assert ('<div class="linenodiv"><pre><span class="normal">1</span>\n'
|
||||
'<span class="normal">2</span>\n'
|
||||
'<span class="normal">3</span>\n'
|
||||
@@ -1592,8 +1594,7 @@ def test_html_codeblock_linenos_style_inline(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
|
||||
pygments_version = tuple(LooseVersion(pygments.__version__).version)
|
||||
if pygments_version > (2, 7):
|
||||
if PYGMENTS_VERSION > (2, 7):
|
||||
assert '<span class="linenos">1</span>' in content
|
||||
else:
|
||||
assert '<span class="lineno">1 </span>' in content
|
||||
|
||||
Reference in New Issue
Block a user