Refactor use of sphinx path to pathlib Path

The sphinx.testing.path.path class has been deprecated; refactor to use
pathlib.Path to resolve a number of related test failures.

Change-Id: I92e1a83f7f053fd2a03ade7b95928faab442b399
This commit is contained in:
James Page 2024-01-19 10:49:14 +00:00
parent 4c78681bea
commit 94fac17921
No known key found for this signature in database
GPG Key ID: BFECAECBA0E7D8C3
1 changed files with 6 additions and 5 deletions

View File

@ -14,12 +14,13 @@
# under the License.
import os
import pathlib
import shutil
import fixtures
import tempfile
import testtools
from sphinx.testing.path import path
from sphinx.testing.util import SphinxTestApp
@ -33,15 +34,15 @@ _TRUE_VALUES = ('True', 'true', '1', 'yes')
class with_app:
def __init__(self, **kwargs):
if 'srcdir' in kwargs:
self.srcdir = path(kwargs['srcdir'])
self.srcdir = pathlib.Path(kwargs['srcdir'])
self.sphinx_app_args = kwargs
def __call__(self, f):
def newf(*args, **kwargs):
with tempfile.TemporaryDirectory() as tmpdirname:
tmpdir = path(tmpdirname)
tmproot = tmpdir / self.srcdir.basename()
self.srcdir.copytree(tmproot)
tmpdir = pathlib.Path(tmpdirname)
tmproot = tmpdir / self.srcdir.name
shutil.copytree(self.srcdir, tmproot)
self.sphinx_app_args['srcdir'] = tmproot
self.builddir = tmproot.joinpath('_build')