Remove deprecated sphinx-testing dependency
This patch replaces the sphinx-testing package using the SphinxTestApp provided by the Sphinx package. The sphinx-testing package is deprecated and should be replaced with the sphinx.testing package that's bundled with Sphinx. Change-Id: I60b4d1a8b83dc35c394e29d746a2fbb3ff744c1a
This commit is contained in:
parent
d3c6dd2c0c
commit
06cd5abff4
|
@ -16,8 +16,12 @@
|
|||
import os
|
||||
|
||||
import fixtures
|
||||
import tempfile
|
||||
import testtools
|
||||
|
||||
from sphinx.testing.path import path
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def example_dir(name=""):
|
||||
return os.path.join(os.path.dirname(__file__), 'examples', name)
|
||||
|
@ -26,6 +30,29 @@ def example_dir(name=""):
|
|||
_TRUE_VALUES = ('True', 'true', '1', 'yes')
|
||||
|
||||
|
||||
class with_app:
|
||||
def __init__(self, **kwargs):
|
||||
if 'srcdir' in kwargs:
|
||||
self.srcdir = 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)
|
||||
self.sphinx_app_args['srcdir'] = tmproot
|
||||
self.builddir = tmproot.joinpath('_build')
|
||||
|
||||
app = SphinxTestApp(freshenv=True, **self.sphinx_app_args)
|
||||
|
||||
f(*args, app, app._status, app._warning, **kwargs)
|
||||
|
||||
app.cleanup()
|
||||
return newf
|
||||
|
||||
|
||||
class OutputStreamCapture(fixtures.Fixture):
|
||||
"""Capture output streams during tests.
|
||||
|
||||
|
|
|
@ -18,23 +18,10 @@ Tests for `os_api_ref` module.
|
|||
"""
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
import sphinx
|
||||
from sphinx_testing import with_app
|
||||
|
||||
from os_api_ref.tests import base
|
||||
|
||||
|
||||
# FIXME(stephenfin): This is horrible. We're monkeypatching this to work around
|
||||
# the fact that Sphinx 1.8+ started called 'abspath' from within the
|
||||
# 'sphinx.application.Application' class [1]. This means our careful use of
|
||||
# 'sphinx_testing.path.path' for 'Application.outdir' etc. gets stomped on.
|
||||
# We're correcting that but we're doing so globally because mock doesn't work
|
||||
# for some reason and this is bound to have some side effects
|
||||
#
|
||||
# [1] https://github.com/sphinx-doc/sphinx/commit/3a85b3502f
|
||||
sphinx.application.abspath = lambda x: x
|
||||
|
||||
|
||||
class TestBasicExample(base.TestCase):
|
||||
"""Test basic rendering.
|
||||
|
||||
|
@ -42,8 +29,7 @@ class TestBasicExample(base.TestCase):
|
|||
examples, so if someone breaks something we know.
|
||||
"""
|
||||
|
||||
@with_app(buildername='html', srcdir=base.example_dir('basic'),
|
||||
copy_srcdir_to_tmpdir=True)
|
||||
@base.with_app(buildername='html', srcdir=base.example_dir('basic'))
|
||||
def setUp(self, app, status, warning):
|
||||
super(TestBasicExample, self).setUp()
|
||||
self.app = app
|
||||
|
|
|
@ -18,7 +18,6 @@ Tests for `os_api_ref` module.
|
|||
"""
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from sphinx_testing import with_app
|
||||
|
||||
from os_api_ref.tests import base
|
||||
|
||||
|
@ -30,8 +29,8 @@ class TestMicroversions(base.TestCase):
|
|||
examples, so if someone breaks something we know.
|
||||
"""
|
||||
|
||||
@with_app(buildername='html', srcdir=base.example_dir('microversions'),
|
||||
copy_srcdir_to_tmpdir=True)
|
||||
@base.with_app(buildername='html',
|
||||
srcdir=base.example_dir('microversions'))
|
||||
def setUp(self, app, status, warning):
|
||||
super(TestMicroversions, self).setUp()
|
||||
self.app = app
|
||||
|
|
|
@ -18,7 +18,6 @@ Tests for `os_api_ref` module.
|
|||
"""
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from sphinx_testing import with_app
|
||||
|
||||
from os_api_ref.tests import base
|
||||
|
||||
|
@ -30,8 +29,7 @@ class TestWarnings(base.TestCase):
|
|||
examples, so if someone breaks something we know.
|
||||
"""
|
||||
|
||||
@with_app(buildername='html', srcdir=base.example_dir('warnings'),
|
||||
copy_srcdir_to_tmpdir=True)
|
||||
@base.with_app(buildername='html', srcdir=base.example_dir('warnings'))
|
||||
def setUp(self, app, status, warning):
|
||||
super(TestWarnings, self).setUp()
|
||||
self.app = app
|
||||
|
|
|
@ -8,7 +8,6 @@ coverage!=4.4,>=4.0 # Apache-2.0
|
|||
python-subunit>=1.0.0 # Apache-2.0/BSD
|
||||
testrepository>=0.0.18 # Apache-2.0/BSD
|
||||
testtools>=2.2.0 # MIT
|
||||
sphinx-testing>=1.0.1 # BSD License
|
||||
beautifulsoup4>=4.6.0 # MIT
|
||||
stestr>=2.0.0 # Apache-2.0
|
||||
pre-commit>=2.6.0 # MIT
|
||||
|
|
Loading…
Reference in New Issue