From 42053b1f92a9eef85e5cca5af0254a961cb6c04e Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 21 Oct 2021 10:04:51 +0100 Subject: [PATCH] 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 --- doc/requirements.txt | 4 +- os_api_ref/tests/test_basic_example.py | 107 ++----------------------- os_api_ref/tests/test_microversions.py | 50 +----------- requirements.txt | 2 +- 4 files changed, 12 insertions(+), 151 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 98bf3f0..801d59e 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -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 \ No newline at end of file +sphinx>=4.0.0 # BSD +openstackdocstheme>=2.2.1 # Apache-2.0 diff --git a/os_api_ref/tests/test_basic_example.py b/os_api_ref/tests/test_basic_example.py index dcfb7d7..4a82a6a 100644 --- a/os_api_ref/tests/test_basic_example.py +++ b/os_api_ref/tests/test_basic_example.py @@ -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 = """
@@ -115,40 +108,11 @@ class TestBasicExample(base.TestCase): -

The name of things

""".format('center' if sphinx.version_info < (2, 1, 0) - else 'default') - else: - table = """ ------ - - - - - - - - - - - - - -
NameInTypeDescription
namebodystringThe name of things
""" - 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 = """ + success_table = """
@@ -169,10 +133,9 @@ class TestBasicExample(base.TestCase): -

Resource was created and is ready to use.

""".format('center' if sphinx.version_info < (2, 1, 0) - else 'default') +""" - error_table = """ + error_table = """
@@ -202,65 +165,7 @@ class TestBasicExample(base.TestCase): -

There is already a zone with this name.

""".format('center' if sphinx.version_info < (2, 1, 0) - else 'default') - else: - success_table = """table border="1" class="docutils"> - - - - - -Code -Reason - - - -200 - OK -Request was successful. - -100 - Continue -An unusual code for an API - -201 - Created -Resource was created and is ready to use. - - - -""" - - error_table = """ ---- - - - - - - - - - - - - - - - - - - - - - - - - - -
CodeReason
405 - Method Not AllowedMethod is not valid for this endpoint.
403 - ForbiddenPolicy does not allow current user to do this operation.
401 - UnauthorizedUser must authenticate before making a request
400 - Bad RequestSome content in the request was invalid
500 - Internal Server ErrorSomething went wrong inside the service.
409 - ConflictThere is already a zone with this name.
-""" +""" self.assertIn(success_table, self.content) self.assertIn(error_table, self.content) diff --git a/os_api_ref/tests/test_microversions.py b/os_api_ref/tests/test_microversions.py index 9aa4bf2..7da8c2f 100644 --- a/os_api_ref/tests/test_microversions.py +++ b/os_api_ref/tests/test_microversions.py @@ -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 = """
- + table = """ +
@@ -94,49 +92,7 @@ class TestMicroversions(base.TestCase):
-
-""".format('center' if sphinx.version_info < (2, 1, 0) else 'default') # noqa - else: - table = """
- ------ - - - - - - - - - - - - - - - - - - - - - - - - -
NameInTypeDescription
namebodystringThe name of things
name2bodystring

The name of things

-

New in version 2.11

-
name3bodystring

The name of things

-

Available until version 2.20

-
-
-""" # noqa - +""" self.assertIn(table, self.content) def test_mv_selector(self): diff --git a/requirements.txt b/requirements.txt index 063a0b5..edc30e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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