From 6c6a289899099f7254a77feb18fb2fc7460f7c12 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 20 Sep 2023 08:15:41 -0300 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=AA=20Fix=20Sphinx=207.2=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_renderers/fixtures/mock_include.md | 4 +++ .../fixtures/sphinx_directives.md | 12 +++---- tests/test_renderers/test_fixtures_sphinx.py | 12 +++---- .../test_renderers/test_include_directive.py | 5 --- tests/test_renderers/test_myst_refs.py | 1 + tests/test_sphinx/conftest.py | 8 +++++ tests/test_sphinx/test_sphinx_builds.py | 31 +++++++++---------- .../test_fieldlist_extension.xml | 4 +-- .../test_sphinx_builds/test_includes.html | 4 +-- .../test_sphinx_builds/test_includes.xml | 3 ++ 10 files changed, 46 insertions(+), 38 deletions(-) diff --git a/tests/test_renderers/fixtures/mock_include.md b/tests/test_renderers/fixtures/mock_include.md index 32d779e5..18d0583d 100644 --- a/tests/test_renderers/fixtures/mock_include.md +++ b/tests/test_renderers/fixtures/mock_include.md @@ -57,6 +57,10 @@ Include code: a + + b + + c . diff --git a/tests/test_renderers/fixtures/sphinx_directives.md b/tests/test_renderers/fixtures/sphinx_directives.md index 2b924572..bb2ba2df 100644 --- a/tests/test_renderers/fixtures/sphinx_directives.md +++ b/tests/test_renderers/fixtures/sphinx_directives.md @@ -21,8 +21,8 @@ object (`sphinx.directives.ObjectDescription`): . - - + + something @@ -404,8 +404,8 @@ cmdoption (`sphinx.domains.std.Cmdoption`): . - - + + a @@ -419,8 +419,8 @@ rst:directive (`sphinx.domains.rst.ReSTDirective`): . - - + + .. a:: diff --git a/tests/test_renderers/test_fixtures_sphinx.py b/tests/test_renderers/test_fixtures_sphinx.py index 54636bca..6a9f88a2 100644 --- a/tests/test_renderers/test_fixtures_sphinx.py +++ b/tests/test_renderers/test_fixtures_sphinx.py @@ -80,13 +80,11 @@ def test_sphinx_directives(file_params, sphinx_doctree_no_tr: CreateDoctree): # see https://github.com/executablebooks/MyST-Parser/issues/522 if sys.maxsize == 2147483647: pformat = pformat.replace('"2147483647"', '"9223372036854775807"') - # changed in sphinx 5.3 for desc node - pformat = pformat.replace('nocontentsentry="False" ', "") - pformat = pformat.replace('noindexentry="False" ', "") - # changed in sphinx 5.3 for desc_signature node - pformat = pformat.replace('_toc_name="" _toc_parts="()" ', "") - pformat = pformat.replace('_toc_name=".. a::" _toc_parts="(\'a\',)" ', "") - pformat = pformat.replace('fullname="a" ', "") + # changed in sphinx 7.1 + pformat = pformat.replace('classes="sig sig-object sig sig-object"', 'classes="sig sig-object"') + pformat = pformat.replace('classes="sig-name descname sig-name descname"', 'classes="sig-name descname"') + pformat = pformat.replace('classes="sig-prename descclassname sig-prename descclassname"', 'classes="sig-prename descclassname"') + file_params.assert_expected(pformat, rstrip_lines=True) diff --git a/tests/test_renderers/test_include_directive.py b/tests/test_renderers/test_include_directive.py index 2bbe4a3d..51d421e6 100644 --- a/tests/test_renderers/test_include_directive.py +++ b/tests/test_renderers/test_include_directive.py @@ -24,11 +24,6 @@ def test_render(file_params, tmp_path, monkeypatch): ) doctree["source"] = "tmpdir/test.md" - if file_params.title.startswith("Include code:"): - # from sphinx 5.3 whitespace nodes are now present - for node in doctree.traverse(): - if node.tagname == "inline" and node["classes"] == ["whitespace"]: - node.parent.remove(node) output = doctree.pformat().replace(str(tmp_path) + os.sep, "tmpdir/").rstrip() file_params.assert_expected(output, rstrip=True) diff --git a/tests/test_renderers/test_myst_refs.py b/tests/test_renderers/test_myst_refs.py index b7d3e56d..6412eadc 100644 --- a/tests/test_renderers/test_myst_refs.py +++ b/tests/test_renderers/test_myst_refs.py @@ -35,6 +35,7 @@ def test_parse( assert not result.warnings doctree["source"] = "root/index.md" + doctree.attributes.pop("translation_progress", None) outcome = doctree.pformat() if result.warnings.strip(): outcome += "\n\n" + result.warnings.strip().replace("", "").replace( diff --git a/tests/test_sphinx/conftest.py b/tests/test_sphinx/conftest.py index 0e25b6ce..a2c41233 100644 --- a/tests/test_sphinx/conftest.py +++ b/tests/test_sphinx/conftest.py @@ -36,6 +36,7 @@ def test_basic(app, status, warning, get_sphinx_app_output): import shutil import pytest +from docutils import nodes from bs4 import BeautifulSoup from sphinx.testing.path import path @@ -116,6 +117,13 @@ def read( ): node["source"] = pathlib.Path(node["source"]).name + doctree = doctree.deepcopy() + + # remove attrs added in sphinx 7.1 + doctree.attributes.pop("translation_progress", None) + for node in findall(doctree)(nodes.Element): + node.attributes.pop("translated", None) + if regress: text = doctree.pformat() # type: str for find, rep in (replace or {}).items(): diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py index db376e18..472ba056 100644 --- a/tests/test_sphinx/test_sphinx_builds.py +++ b/tests/test_sphinx/test_sphinx_builds.py @@ -41,6 +41,10 @@ def test_basic( app, docname="content", regress=True, + replace={ + # changed in sphinx 7.1 + '': '', + } ) finally: get_sphinx_app_doctree( @@ -48,6 +52,10 @@ def test_basic( docname="content", resolve=True, regress=True, + replace={ + # changed in sphinx 7.1 + '': '', + } ) get_sphinx_app_output( app, @@ -257,8 +265,6 @@ def test_includes( r"subfolder\example2.jpg": "subfolder/example2.jpg", r"subfolder\\example2.jpg": "subfolder/example2.jpg", r"subfolder\\\\example2.jpg": "subfolder/example2.jpg", - # in sphinx 5.3 whitespace nodes were added - ' \n ': "", }, ) finally: @@ -271,9 +277,6 @@ def test_includes( r"'subfolder\\example2'": "'subfolder/example2'", r'uri="subfolder\\example2"': 'uri="subfolder/example2"', "_images/example21.jpg": "_images/example2.jpg", - # in sphinx 5.3 whitespace nodes were added - '': "", - '\n': "\n", }, ) @@ -539,17 +542,13 @@ def test_fieldlist_extension( docname="index", regress=True, replace={ - # changed in: - # https://www.sphinx-doc.org/en/master/changes.html#release-4-4-0-released-jan-17-2022 - ( - '' - ): "", - # changed in sphinx 5.3, for `desc` node - 'nocontentsentry="False" ': "", - 'noindexentry="False" ': "", - # changed in sphinx 5.3, for `desc_signature` node - '_toc_name="send_message()" _toc_parts="(\'send_message\',)" ': "", + # changed in sphinx 7.1 for desc_sig_name node + 'classes="n n"': 'classes="n"', + # changed in sphinx 7.1 for desc_parameterlist node + 'multi_line_parameter_list="False" ': '', + # changed in sphinx 7.1 for desc_signature/desc_name nodes + 'classes="sig sig-object sig sig-object"': 'classes="sig sig-object"', + 'classes="sig-name descname sig-name descname"': 'classes="sig-name descname"', }, ) finally: diff --git a/tests/test_sphinx/test_sphinx_builds/test_fieldlist_extension.xml b/tests/test_sphinx/test_sphinx_builds/test_fieldlist_extension.xml index bb5d11e8..31648faf 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_fieldlist_extension.xml +++ b/tests/test_sphinx/test_sphinx_builds/test_fieldlist_extension.xml @@ -15,8 +15,8 @@ content - - + + send_message diff --git a/tests/test_sphinx/test_sphinx_builds/test_includes.html b/tests/test_sphinx/test_sphinx_builds/test_includes.html index 2c1b6d88..89a477d7 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_includes.html +++ b/tests/test_sphinx/test_sphinx_builds/test_includes.html @@ -102,8 +102,8 @@

-
0 def a_func(param):
-1     print(param)
+
0 def a_func(param):
+1     print(param)
This should be *literal*
diff --git a/tests/test_sphinx/test_sphinx_builds/test_includes.xml b/tests/test_sphinx/test_sphinx_builds/test_includes.xml
index 64ff16ab..65a197bd 100644
--- a/tests/test_sphinx/test_sphinx_builds/test_includes.xml
+++ b/tests/test_sphinx/test_sphinx_builds/test_includes.xml
@@ -56,6 +56,7 @@
                     param
                 
                     ):
+                
 
 
                 
@@ -80,9 +81,11 @@
                     param
                 
                     ):
+                
 
                 
                     1
+                
 
                 
                     print

From a61053e1554a4aa9b51f9b83da6560e9d533edc6 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
 <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Wed, 20 Sep 2023 11:16:15 +0000
Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
---
 tests/test_renderers/test_fixtures_sphinx.py | 15 +++++++++++----
 tests/test_sphinx/conftest.py                |  2 +-
 tests/test_sphinx/test_sphinx_builds.py      |  6 +++---
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/tests/test_renderers/test_fixtures_sphinx.py b/tests/test_renderers/test_fixtures_sphinx.py
index 6a9f88a2..01332049 100644
--- a/tests/test_renderers/test_fixtures_sphinx.py
+++ b/tests/test_renderers/test_fixtures_sphinx.py
@@ -81,10 +81,17 @@ def test_sphinx_directives(file_params, sphinx_doctree_no_tr: CreateDoctree):
     if sys.maxsize == 2147483647:
         pformat = pformat.replace('"2147483647"', '"9223372036854775807"')
     # changed in sphinx 7.1
-    pformat = pformat.replace('classes="sig sig-object sig sig-object"', 'classes="sig sig-object"')
-    pformat = pformat.replace('classes="sig-name descname sig-name descname"', 'classes="sig-name descname"')
-    pformat = pformat.replace('classes="sig-prename descclassname sig-prename descclassname"', 'classes="sig-prename descclassname"')
-    
+    pformat = pformat.replace(
+        'classes="sig sig-object sig sig-object"', 'classes="sig sig-object"'
+    )
+    pformat = pformat.replace(
+        'classes="sig-name descname sig-name descname"', 'classes="sig-name descname"'
+    )
+    pformat = pformat.replace(
+        'classes="sig-prename descclassname sig-prename descclassname"',
+        'classes="sig-prename descclassname"',
+    )
+
     file_params.assert_expected(pformat, rstrip_lines=True)
 
 
diff --git a/tests/test_sphinx/conftest.py b/tests/test_sphinx/conftest.py
index a2c41233..b3f95d53 100644
--- a/tests/test_sphinx/conftest.py
+++ b/tests/test_sphinx/conftest.py
@@ -36,8 +36,8 @@ def test_basic(app, status, warning, get_sphinx_app_output):
 import shutil
 
 import pytest
-from docutils import nodes
 from bs4 import BeautifulSoup
+from docutils import nodes
 from sphinx.testing.path import path
 
 from myst_parser._compat import findall
diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py
index 472ba056..fdb358e0 100644
--- a/tests/test_sphinx/test_sphinx_builds.py
+++ b/tests/test_sphinx/test_sphinx_builds.py
@@ -44,7 +44,7 @@ def test_basic(
             replace={
                 # changed in sphinx 7.1
                 '': '',
-            }
+            },
         )
     finally:
         get_sphinx_app_doctree(
@@ -55,7 +55,7 @@ def test_basic(
             replace={
                 # changed in sphinx 7.1
                 '': '',
-            }
+            },
         )
     get_sphinx_app_output(
         app,
@@ -545,7 +545,7 @@ def test_fieldlist_extension(
                 # changed in sphinx 7.1 for desc_sig_name node
                 'classes="n n"': 'classes="n"',
                 # changed in sphinx 7.1 for desc_parameterlist node
-                'multi_line_parameter_list="False" ': '',
+                'multi_line_parameter_list="False" ': "",
                 # changed in sphinx 7.1 for desc_signature/desc_name nodes
                 'classes="sig sig-object sig sig-object"': 'classes="sig sig-object"',
                 'classes="sig-name descname sig-name descname"': 'classes="sig-name descname"',

From ba63e438e9b034a61249ca949b6a0af4292bbafe Mon Sep 17 00:00:00 2001
From: Chris Sewell 
Date: Wed, 20 Sep 2023 10:04:43 -0300
Subject: [PATCH 3/3] more

---
 tests/test_renderers/test_fixtures_sphinx.py | 10 +++++++++-
 tests/test_sphinx/conftest.py                |  2 ++
 tests/test_sphinx/test_sphinx_builds.py      | 17 ++++++++++++++---
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/tests/test_renderers/test_fixtures_sphinx.py b/tests/test_renderers/test_fixtures_sphinx.py
index 01332049..d37ed617 100644
--- a/tests/test_renderers/test_fixtures_sphinx.py
+++ b/tests/test_renderers/test_fixtures_sphinx.py
@@ -80,7 +80,7 @@ def test_sphinx_directives(file_params, sphinx_doctree_no_tr: CreateDoctree):
     # see https://github.com/executablebooks/MyST-Parser/issues/522
     if sys.maxsize == 2147483647:
         pformat = pformat.replace('"2147483647"', '"9223372036854775807"')
-    # changed in sphinx 7.1
+    # changed in sphinx 7.2
     pformat = pformat.replace(
         'classes="sig sig-object sig sig-object"', 'classes="sig sig-object"'
     )
@@ -91,6 +91,14 @@ def test_sphinx_directives(file_params, sphinx_doctree_no_tr: CreateDoctree):
         'classes="sig-prename descclassname sig-prename descclassname"',
         'classes="sig-prename descclassname"',
     )
+    # changed in sphinx 7.2 (#11533)
+    pformat = pformat.replace(
+        (
+            'no-contents-entry="False" no-index="False" '
+            'no-index-entry="False" no-typesetting="False" '
+        ),
+        "",
+    )
 
     file_params.assert_expected(pformat, rstrip_lines=True)
 
diff --git a/tests/test_sphinx/conftest.py b/tests/test_sphinx/conftest.py
index b3f95d53..4a244872 100644
--- a/tests/test_sphinx/conftest.py
+++ b/tests/test_sphinx/conftest.py
@@ -84,6 +84,8 @@ def read(
             for pygment_whitespace in doc_div.select("pre > span.w"):
                 pygment_whitespace.replace_with(pygment_whitespace.text)
             text = doc_div.prettify()
+            # changed in sphinx 7.2
+            text = text.replace('"Link to this', '"Permalink to this')
             for find, rep in (replace or {}).items():
                 text = text.replace(find, rep)
             file_regression.check(text, extension=regress_ext, encoding="utf8")
diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py
index fdb358e0..a1d6f0b1 100644
--- a/tests/test_sphinx/test_sphinx_builds.py
+++ b/tests/test_sphinx/test_sphinx_builds.py
@@ -265,6 +265,8 @@ def test_includes(
                 r"subfolder\example2.jpg": "subfolder/example2.jpg",
                 r"subfolder\\example2.jpg": "subfolder/example2.jpg",
                 r"subfolder\\\\example2.jpg": "subfolder/example2.jpg",
+                # added in sphinx 7.2 (#9846)
+                'original_uri="/subfolder/example2.jpg" ': "",
             },
         )
     finally:
@@ -460,6 +462,10 @@ def test_gettext_html(
         filename="index.html",
         regress_html=True,
         regress_ext=".html",
+        replace={
+            # upstream bug https://github.com/sphinx-doc/sphinx/issues/11689
+            '"Permalink to this heading"': '"Lien permanent vers cette rubrique"'
+        },
     )
 
 
@@ -542,13 +548,18 @@ def test_fieldlist_extension(
             docname="index",
             regress=True,
             replace={
-                # changed in sphinx 7.1 for desc_sig_name node
+                # changed in sphinx 7.2 for desc_sig_name node
                 'classes="n n"': 'classes="n"',
-                # changed in sphinx 7.1 for desc_parameterlist node
+                # changed in sphinx 7.2 for desc_parameterlist node
                 'multi_line_parameter_list="False" ': "",
-                # changed in sphinx 7.1 for desc_signature/desc_name nodes
+                # changed in sphinx 7.2 for desc_signature/desc_name nodes
                 'classes="sig sig-object sig sig-object"': 'classes="sig sig-object"',
                 'classes="sig-name descname sig-name descname"': 'classes="sig-name descname"',
+                # changed in sphinx 7.2 (#11533)
+                (
+                    'no-contents-entry="False" no-index="False" '
+                    'no-index-entry="False" no-typesetting="False" '
+                ): "",
             },
         )
     finally: