Skip to content

Commit

Permalink
[#69] fix deprecation warning (#70)
Browse files Browse the repository at this point in the history
* [#69] remove deprecation warnings from sphinx

* differ between sphinx-versions 6 and 7

* linting issues

* use exact versions from sphinx changelog

* upgrade to sphinx 7.2.6

* fix deprecations due to version checking

* fix lint issues
  • Loading branch information
kreuzberger authored Apr 2, 2024
1 parent 405253a commit a8da8e8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from nox import session

PYTHON_VERSIONS = ["3.8", "3.9", "3.10"]
SPHINX_VERSIONS = ["5.0"]
SPHINX_VERSIONS = ["5.0", "6.2.1", "7.1.2", "7.2.5"]
TEST_DEPENDENCIES = [
"pytest",
"pytest-xdist",
Expand Down
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
12 changes: 8 additions & 4 deletions sphinxcontrib/test_reports/environment.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
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"):
from sphinx.util import status_iterator # NOQA Sphinx 1.5
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

STATICS_DIR_NAME = "_static"

Expand Down Expand Up @@ -80,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
22 changes: 16 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
"""Pytest conftest module containing common test configuration and fixtures."""
import shutil
from pathlib import Path
from tempfile import mkdtemp

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

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


pytest_plugins = "sphinx.testing.fixtures"


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


@pytest.fixture(scope="function")
def test_app(make_app, request):
# We create a temp-folder on our own, as the util-functions from sphinx and pytest make troubles.
# It seems like they reuse certain-temp names
sphinx_test_tempdir = path(mkdtemp())
sphinx_test_tempdir = Path(mkdtemp())

builder_params = request.param

# copy plantuml.jar, xml files and json files to current test temdir
util_files = path(__file__).parent.abspath() / "doc_test/utils"
util_files = Path(__file__).parent.absolute() / "doc_test/utils"
shutil.copytree(util_files, sphinx_test_tempdir / "utils")

# copy test srcdir to test temporary directory sphinx_test_tempdir
Expand Down

0 comments on commit a8da8e8

Please sign in to comment.