Skip to content

Commit

Permalink
fix deprecations due to version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
kreuzberger committed Jan 19, 2024
1 parent 837afbf commit 1b89989
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions sphinxcontrib/test_reports/directives/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import sphinx
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from pkg_resources import parse_version
from packaging.version import Version

sphinx_version = sphinx.__version__
if parse_version(sphinx_version) >= parse_version("1.6"):
if Version(sphinx_version) >= Version("1.6"):
from sphinx.util import logging
else:
import logging
Expand Down
9 changes: 5 additions & 4 deletions sphinxcontrib/test_reports/environment.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import os

import sphinx
from pkg_resources import parse_version
from packaging.version import Version

from sphinx.util.console import brown
from sphinx.util.osutil import copyfile, ensuredir

sphinx_version = sphinx.__version__
if parse_version(sphinx_version) >= parse_version("1.6"):
if parse_version(sphinx_version) >= parse_version("6.1"):
if Version(sphinx_version) >= Version("1.6"):
if Version(sphinx_version) >= Version("6.1"):
from sphinx.util.display import status_iterator
else:
from sphinx.util import status_iterator # NOQA Sphinx 1.5
Expand Down Expand Up @@ -83,7 +84,7 @@ def install_styles_static_files(app, env):
# Be sure no "old" css layout is already set
safe_remove_file("sphinx-test-reports/common.css", app)

if parse_version(sphinx_version) < parse_version("1.6"):
if Version(sphinx_version) < Version("1.6"):
global status_iterator
status_iterator = app.status_iterator

Expand Down
4 changes: 2 additions & 2 deletions sphinxcontrib/test_reports/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os

import sphinx
from packaging.version import Version
# from docutils import nodes
from pkg_resources import parse_version
from sphinx_needs.api import (add_dynamic_function, add_extra_option,
add_need_type)

Expand All @@ -23,7 +23,7 @@
from sphinxcontrib.test_reports.functions import tr_link

sphinx_version = sphinx.__version__
if parse_version(sphinx_version) >= parse_version("1.6"):
if Version(sphinx_version) >= Version("1.6"):
from sphinx.util import logging
else:
import logging
Expand Down
12 changes: 8 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@
import shutil
from pathlib import Path
from tempfile import mkdtemp
import os.path

import pytest
from pkg_resources import parse_version

from packaging.version import Version
from sphinx import __version__ as sphinx_version
from sphinx.testing.path import path

if Version(sphinx_version) < Version("7.2"):
from sphinx.testing.path import path


pytest_plugins = "sphinx.testing.fixtures"

pytest_plugins = "sphinx.testing.fixtures"

def copy_srcdir_to_tmpdir(srcdir, tmp):
srcdir = Path(__file__).parent.absolute() / srcdir
tmproot = tmp / Path(srcdir).name
shutil.copytree(srcdir, tmproot)
return (
tmproot
if parse_version(sphinx_version) >= parse_version("7.2")
if Version(sphinx_version) >= Version("7.2")
else path(tmproot.absolute())
)

Expand Down

0 comments on commit 1b89989

Please sign in to comment.