Series of job fixes

The time passes and things stop to work which worked before.
Unfortunately now we landed in the situation that we can't fix issues
independently due to their collision so we need to address few things in
one change:

- Replace deprecated sphinx.testing.path

  The sphinx.testing.path moudle was deprecated in sphinx v7.2.0[1].
  Also remove the colgroup section causing the assertion failures.

  The changes made in unit tests require Sphinx v7.2.0 or later, but
  Sphinx is capped to 7.1.2 in Python 3.8. So unit tests may no longer
  pass in Python 3.8 once this change is merged.

  [1] https://github.com/sphinx-doc/sphinx/pull/11526

- Since we stop testing py38 update classifiers

- py312 dropped assertRegexpMatches (replace with AssertRegex)

- py312 changed how OrderedDict is serialized and as such test asserting
  certain serialization form is now failing. Address this by using
  OrderedDict directly in the comparison rather then hardcoding the form
  since onlt that would work in different python versions.

Change-Id: I01a89777e18fb6f21f92a297f605099c5971583c
This commit is contained in:
Takashi Kajinami
2024-04-21 03:00:56 +09:00
committed by Artem Goncharov
parent 4c78681bea
commit 561ed1cb5f
6 changed files with 25 additions and 33 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
@@ -32,16 +33,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.joinpath(self.srcdir.name)
shutil.copytree(self.srcdir, tmproot)
self.sphinx_app_args['srcdir'] = tmproot
self.builddir = tmproot.joinpath('_build')

View File

@@ -74,12 +74,6 @@ class TestBasicExample(base.TestCase):
def test_parameters(self):
"""Do we get some parameters table"""
table = """<table class="docutils align-default">
<colgroup>
<col style="width: 20%"/>
<col style="width: 10%"/>
<col style="width: 10%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>In</p></th>
@@ -99,10 +93,6 @@ class TestBasicExample(base.TestCase):
def test_rest_response(self):
success_table = """<table class="docutils align-default">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Code</p></th>
<th class="head"><p>Reason</p></th>
@@ -122,10 +112,6 @@ class TestBasicExample(base.TestCase):
</table>"""
error_table = """<table class="docutils align-default">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Code</p></th>
<th class="head"><p>Reason</p></th>

View File

@@ -44,11 +44,11 @@ class TestMicroversions(base.TestCase):
def test_rest_method(self):
"""Test that min / max mv css class attributes are set"""
content = self.soup.find_all(class_='rp_min_ver_2_17')
self.assertRegexpMatches(
self.assertRegex(
str(content[0]),
'^<div class="operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ?"')
content = self.soup.find_all(class_='rp_max_ver_2_19')
self.assertRegexpMatches(
self.assertRegex(
str(content[0]),
'^<div class="operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ?"')
@@ -56,12 +56,6 @@ class TestMicroversions(base.TestCase):
"""Test that min / max mv css class attributes are set in params"""
table = """
<table class="docutils align-default">
<colgroup>
<col style="width: 20%"/>
<col style="width: 10%"/>
<col style="width: 10%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>In</p></th>

View File

@@ -17,6 +17,8 @@ test_os_api_ref
Tests for `os_api_ref` module.
"""
from collections import OrderedDict
from bs4 import BeautifulSoup
from os_api_ref.tests import base
@@ -55,11 +57,16 @@ class TestWarnings(base.TestCase):
def test_missing_field(self):
"""Warning when missing type field in parameter file."""
# py312 changes string interpretation of OrderedDict.
# Prevent such failures by using OrderedDict directly
cmp_data = OrderedDict({
"description": "name_1 is missing type field.\n",
"in": "body",
"required": True
})
self.assertIn(
("WARNING: Failure on key: name, values: " +
"OrderedDict([('description'," +
" 'name_1 is missing type field.\\n'), ('in', 'body')," +
" ('required', True)]). " +
f"{cmp_data}. " +
"'NoneType' object has no attribute 'split'"),
self.warning)

View File

@@ -6,7 +6,7 @@ description_file =
author = OpenStack
author_email = openstack-discuss@lists.openstack.org
home_page = https://docs.openstack.org/os-api-ref/latest/
python_requires = >=3.8
python_requires = >=3.9
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
@@ -15,8 +15,10 @@ classifier =
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython

View File

@@ -11,3 +11,6 @@ testtools>=2.2.0 # MIT
beautifulsoup4>=4.6.0 # MIT
stestr>=2.0.0 # Apache-2.0
pre-commit>=2.6.0 # MIT
# The minimum version requirement is specific to unit tests.
sphinx>=7.2.0 # BSD