From 1b89989df5c2ff734576895c7efe2ea4327f5f88 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 19 Jan 2024 18:22:38 +0100 Subject: [PATCH] fix deprecations due to version checking --- sphinxcontrib/test_reports/directives/test_env.py | 4 ++-- sphinxcontrib/test_reports/environment.py | 9 +++++---- sphinxcontrib/test_reports/test_reports.py | 4 ++-- tests/conftest.py | 12 ++++++++---- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sphinxcontrib/test_reports/directives/test_env.py b/sphinxcontrib/test_reports/directives/test_env.py index de05467..dea4ade 100644 --- a/sphinxcontrib/test_reports/directives/test_env.py +++ b/sphinxcontrib/test_reports/directives/test_env.py @@ -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 diff --git a/sphinxcontrib/test_reports/environment.py b/sphinxcontrib/test_reports/environment.py index 56832c7..2c37e1f 100644 --- a/sphinxcontrib/test_reports/environment.py +++ b/sphinxcontrib/test_reports/environment.py @@ -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 @@ -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 diff --git a/sphinxcontrib/test_reports/test_reports.py b/sphinxcontrib/test_reports/test_reports.py index 25621c9..118c464 100644 --- a/sphinxcontrib/test_reports/test_reports.py +++ b/sphinxcontrib/test_reports/test_reports.py @@ -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) @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 0b7bb62..e3ba2d4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,15 +2,19 @@ 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 @@ -18,7 +22,7 @@ def copy_srcdir_to_tmpdir(srcdir, tmp): 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()) )