Drop support for Sphinx < 4.x
Our tests are broken due to changes introduced by Sphinx 4.0 and thus require some adaptation. Rather than introduce more logic into tests to handle older versions, simply drop support for older versions of Sphinx. Change-Id: I2e8ff5cc2e6b4703d7f767fc95b6766d727d8577 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
79b9b698d9
commit
42053b1f92
@ -1,5 +1,5 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
sphinx>=2.0.0,!=2.1.0 # BSD
|
||||
openstackdocstheme>=2.2.1 # Apache-2.0
|
||||
sphinx>=4.0.0 # BSD
|
||||
openstackdocstheme>=2.2.1 # Apache-2.0
|
||||
|
@ -32,10 +32,7 @@ from os_api_ref.tests import base
|
||||
# for some reason and this is bound to have some side effects
|
||||
#
|
||||
# [1] https://github.com/sphinx-doc/sphinx/commit/3a85b3502f
|
||||
try:
|
||||
sphinx.application.abspath = lambda x: x
|
||||
except ImportError: # Sphinx < 1.8
|
||||
pass
|
||||
sphinx.application.abspath = lambda x: x
|
||||
|
||||
|
||||
class TestBasicExample(base.TestCase):
|
||||
@ -90,11 +87,7 @@ class TestBasicExample(base.TestCase):
|
||||
|
||||
def test_parameters(self):
|
||||
"""Do we get some parameters table"""
|
||||
|
||||
# TODO(stephenfin): Drop support for this once we drop support for both
|
||||
# Python 2.7 and Sphinx < 2.0, likely in "U"
|
||||
if sphinx.version_info >= (2, 0, 0):
|
||||
table = """<table class="docutils align-{}">
|
||||
table = """<table class="docutils align-default">
|
||||
<colgroup>
|
||||
<col style="width: 20%"/>
|
||||
<col style="width: 10%"/>
|
||||
@ -115,40 +108,11 @@ class TestBasicExample(base.TestCase):
|
||||
<td><p>The name of things</p></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>""".format('center' if sphinx.version_info < (2, 1, 0)
|
||||
else 'default')
|
||||
else:
|
||||
table = """<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="20%"/>
|
||||
<col width="10%"/>
|
||||
<col width="10%"/>
|
||||
<col width="60%"/>
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr class="row-odd"><th class="head">Name</th>
|
||||
<th class="head">In</th>
|
||||
<th class="head">Type</th>
|
||||
<th class="head">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr class="row-even"><td>name</td>
|
||||
<td>body</td>
|
||||
<td>string</td>
|
||||
<td>The name of things</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>"""
|
||||
|
||||
self.assertIn(table, self.content)
|
||||
|
||||
def test_rest_response(self):
|
||||
|
||||
# TODO(stephenfin): Drop support for this once we drop support for both
|
||||
# Python 2.7 and Sphinx < 2.0, likely in "U"
|
||||
if sphinx.version_info >= (2, 0, 0):
|
||||
success_table = """<table class="docutils align-{}">
|
||||
success_table = """<table class="docutils align-default">
|
||||
<colgroup>
|
||||
<col style="width: 30%"/>
|
||||
<col style="width: 70%"/>
|
||||
@ -169,10 +133,9 @@ class TestBasicExample(base.TestCase):
|
||||
<td><p>Resource was created and is ready to use.</p></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>""".format('center' if sphinx.version_info < (2, 1, 0)
|
||||
else 'default')
|
||||
</table>"""
|
||||
|
||||
error_table = """<table class="docutils align-{}">
|
||||
error_table = """<table class="docutils align-default">
|
||||
<colgroup>
|
||||
<col style="width: 30%"/>
|
||||
<col style="width: 70%"/>
|
||||
@ -202,65 +165,7 @@ class TestBasicExample(base.TestCase):
|
||||
<td><p>There is already a zone with this name.</p></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>""".format('center' if sphinx.version_info < (2, 1, 0)
|
||||
else 'default')
|
||||
else:
|
||||
success_table = """table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="30%"/>
|
||||
<col width="70%"/>
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr class="row-odd"><th class="head">Code</th>
|
||||
<th class="head">Reason</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr class="row-even"><td><code>200 - OK</code></td>
|
||||
<td>Request was successful.</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><code>100 - Continue</code></td>
|
||||
<td>An unusual code for an API</td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><code>201 - Created</code></td>
|
||||
<td>Resource was created and is ready to use.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
"""
|
||||
|
||||
error_table = """<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="30%"/>
|
||||
<col width="70%"/>
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr class="row-odd"><th class="head">Code</th>
|
||||
<th class="head">Reason</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr class="row-even"><td><code>405 - Method Not Allowed</code></td>
|
||||
<td>Method is not valid for this endpoint.</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><code>403 - Forbidden</code></td>
|
||||
<td>Policy does not allow current user to do this operation.</td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><code>401 - Unauthorized</code></td>
|
||||
<td>User must authenticate before making a request</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><code>400 - Bad Request</code></td>
|
||||
<td>Some content in the request was invalid</td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><code>500 - Internal Server Error</code></td>
|
||||
<td>Something went wrong inside the service.</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><code>409 - Conflict</code></td>
|
||||
<td>There is already a zone with this name.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
"""
|
||||
</table>"""
|
||||
|
||||
self.assertIn(success_table, self.content)
|
||||
self.assertIn(error_table, self.content)
|
||||
|
@ -18,7 +18,6 @@ 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
|
||||
@ -56,9 +55,8 @@ class TestMicroversions(base.TestCase):
|
||||
|
||||
def test_parameters_table(self):
|
||||
"""Test that min / max mv css class attributes are set in params"""
|
||||
if sphinx.version_info >= (2, 0, 0):
|
||||
table = """<div class="api-detail collapse section" id="list-servers-detail">
|
||||
<table class="docutils align-{}">
|
||||
table = """
|
||||
<table class="docutils align-default">
|
||||
<colgroup>
|
||||
<col style="width: 20%"/>
|
||||
<col style="width: 10%"/>
|
||||
@ -94,49 +92,7 @@ class TestMicroversions(base.TestCase):
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
""".format('center' if sphinx.version_info < (2, 1, 0) else 'default') # noqa
|
||||
else:
|
||||
table = """<div class="api-detail collapse section" id="list-servers-detail">
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="20%"/>
|
||||
<col width="10%"/>
|
||||
<col width="10%"/>
|
||||
<col width="60%"/>
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr class="row-odd"><th class="head">Name</th>
|
||||
<th class="head">In</th>
|
||||
<th class="head">Type</th>
|
||||
<th class="head">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr class="row-even"><td>name</td>
|
||||
<td>body</td>
|
||||
<td>string</td>
|
||||
<td>The name of things</td>
|
||||
</tr>
|
||||
<tr class="rp_min_ver_2_11 row-odd"><td>name2</td>
|
||||
<td>body</td>
|
||||
<td>string</td>
|
||||
<td><p class="first">The name of things</p>
|
||||
<p class="last"><strong>New in version 2.11</strong></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rp_max_ver_2_20 row-even"><td>name3</td>
|
||||
<td>body</td>
|
||||
<td>string</td>
|
||||
<td><p class="first">The name of things</p>
|
||||
<p class="last"><strong>Available until version 2.20</strong></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
""" # noqa
|
||||
|
||||
"""
|
||||
self.assertIn(table, self.content)
|
||||
|
||||
def test_mv_selector(self):
|
||||
|
@ -5,5 +5,5 @@
|
||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
PyYAML>=3.12 # MIT
|
||||
six>=1.10.0 # MIT
|
||||
sphinx>=2.0.0,!=2.1.0 # BSD
|
||||
sphinx>=4.0.0 # BSD
|
||||
openstackdocstheme>=2.2.1 # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user