executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
708 stars 189 forks source link

Test regressions with Sphinx 7.3.7 #913

Closed mgorny closed 2 months ago

mgorny commented 2 months ago

What version of myst-parser are you using?

707e8a4fd61df8c79ed0d589edb51dd9e23df53c

What version dependencies are you using?

pip list ``` Package Version ----------------------------- -------- alabaster 0.7.16 Babel 2.14.0 beautifulsoup4 4.12.3 certifi 2024.2.2 charset-normalizer 3.3.2 coverage 7.4.4 defusedxml 0.7.1 docutils 0.20.1 exceptiongroup 1.2.1 idna 3.7 imagesize 1.4.1 iniconfig 2.0.0 Jinja2 3.1.3 linkify-it-py 2.0.3 markdown-it-py 3.0.0 MarkupSafe 2.1.5 mdit-py-plugins 0.4.0 mdurl 0.1.2 myst-parser 2.0.0 packaging 24.0 pip 24.0 pluggy 1.5.0 Pygments 2.17.2 pytest 8.1.1 pytest-cov 5.0.0 pytest-datadir 1.5.0 pytest_param_files 0.6.0 pytest-regressions 2.5.0 PyYAML 6.0.1 requests 2.31.0 ruamel.yaml 0.18.6 ruamel.yaml.clib 0.2.8 setuptools 69.1.1 snowballstemmer 2.2.0 soupsieve 2.5 Sphinx 7.3.7 sphinx_pytest 0.2.0 sphinxcontrib-applehelp 1.0.8 sphinxcontrib-devhelp 1.0.6 sphinxcontrib-htmlhelp 2.0.5 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.7 sphinxcontrib-serializinghtml 1.1.10 tomli 2.0.1 uc-micro-py 1.0.3 urllib3 2.2.1 wheel 0.42.0 ```

What operating system are you using?

Linux

Describe the Bug

After upgrading Sphinx to 7.3.7, a handful of tests are failing. FWICS all due to miscellaneous changes in output:

FAILED tests/test_renderers/test_fixtures_sphinx.py::test_syntax_elements[298-Sphinx Role containing backtick:] - AssertionError: actual != expected (use --regen-file-failure)
FAILED tests/test_renderers/test_fixtures_sphinx.py::test_sphinx_directives[341-versionadded (`sphinx.domains.changeset.VersionChange`):] - AssertionError: actual != expected (use --regen-file-failure)
FAILED tests/test_sphinx/test_sphinx_builds.py::test_references_singlehtml - AssertionError: FILES DIFFER:
FAILED tests/test_sphinx/test_sphinx_builds.py::test_heading_slug_func - AssertionError: assert '\x1b[91mWARN...x1b[39;49;00m' == ''
FAILED tests/test_sphinx/test_sphinx_builds.py::test_gettext_html - AssertionError: FILES DIFFER:
Tracebacks ```pytb ============================================================== FAILURES =============================================================== _____________________________________ test_syntax_elements[298-Sphinx Role containing backtick:] ______________________________________ file_params = ParamTestData(line=298, title='Sphinx Role containing backtick:', description=None, content='{code}``a=1{`}``\n', expe...s="code">\n a=1{`}\n', index=22, fmt=, extra={}) sphinx_doctree_no_tr = @pytest.mark.param_file(FIXTURE_PATH / "sphinx_syntax_elements.md") def test_syntax_elements(file_params, sphinx_doctree_no_tr: CreateDoctree): sphinx_doctree_no_tr.set_conf({"extensions": ["myst_parser"]}) result = sphinx_doctree_no_tr(file_params.content, "index.md") > file_params.assert_expected(result.pformat("index"), rstrip_lines=True) E AssertionError: actual != expected (use --regen-file-failure) E --- /tmp/MyST-Parser/tests/test_renderers/fixtures/sphinx_syntax_elements.md:298 E +++ (actual) E @@ -1,4 +1,4 @@ E E E - E + E a=1{`} tests/test_renderers/test_fixtures_sphinx.py:25: AssertionError ________________________ test_sphinx_directives[341-versionadded (`sphinx.domains.changeset.VersionChange`):] _________________________ file_params = ParamTestData(line=341, title='versionadded (`sphinx.domains.changeset.VersionChange`):', description=None, content='`... New in version 0.2.\n', index=27, fmt=, extra={}) sphinx_doctree_no_tr = @pytest.mark.param_file(FIXTURE_PATH / "sphinx_directives.md") def test_sphinx_directives(file_params, sphinx_doctree_no_tr: CreateDoctree): # TODO fix skipped directives # TODO test domain directives if file_params.title.startswith("SKIP") or file_params.title.startswith( "SPHINX4-SKIP" ): pytest.skip(file_params.title) sphinx_doctree_no_tr.set_conf({"extensions": ["myst_parser"]}) pformat = sphinx_doctree_no_tr(file_params.content, "index.md").pformat("index") # see https://github.com/sphinx-doc/sphinx/issues/9827 pformat = pformat.replace('', "") # see https://github.com/executablebooks/MyST-Parser/issues/522 if sys.maxsize == 2147483647: pformat = pformat.replace('"2147483647"', '"9223372036854775807"') # changed in sphinx 7.1 (but fixed in 7.2) 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"', ) # 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) E AssertionError: actual != expected (use --regen-file-failure) E --- /tmp/MyST-Parser/tests/test_renderers/fixtures/sphinx_directives.md:341 E +++ (actual) E @@ -2,4 +2,4 @@ E E E E - New in version 0.2. E + Added in version 0.2. tests/test_renderers/test_fixtures_sphinx.py:104: AssertionError _____________________________________________________ test_references_singlehtml ______________________________________________________ app = , status = <_io.StringIO object at 0x7f6d4d0d5f30> warning = <_io.StringIO object at 0x7f6d4d0d65f0> get_sphinx_app_doctree = .read at 0x7f6d4d0d5900> get_sphinx_app_output = .read at 0x7f6d4d0d5d80> @pytest.mark.sphinx( buildername="singlehtml", srcdir=os.path.join(SOURCE_DIR, "references_singlehtml"), freshenv=True, confoverrides={"nitpicky": True}, ) def test_references_singlehtml( app, status, warning, get_sphinx_app_doctree, get_sphinx_app_output, ): """Test reference resolution for singlehtml builds.""" app.build() assert "build succeeded" in status.getvalue() # Build succeeded warnings = warning.getvalue().strip() assert warnings == "" # try: # get_sphinx_app_doctree(app, docname="index", regress=True) # finally: # get_sphinx_app_doctree(app, docname="index", resolve=True, regress=True) try: get_sphinx_app_doctree( app, docname="other/other", regress=True, replace={"other\\other.md": "other/other.md"}, ) finally: > get_sphinx_app_doctree( app, docname="other/other", resolve=True, regress=True, replace={"other\\other.md": "other/other.md"}, ) tests/test_sphinx/test_sphinx_builds.py:160: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ app = , docname = 'other/other', resolve = True, regress = True replace = {'other\\other.md': 'other/other.md'}, rstrip_lines = False, regress_ext = '.xml' def read( app, docname="index", resolve=False, regress=False, replace=None, rstrip_lines=False, regress_ext=".xml", ): if resolve: doctree = app.env.get_and_resolve_doctree(docname, app.builder) extension = f".resolved{regress_ext}" else: doctree = app.env.get_doctree(docname) extension = regress_ext # convert absolute filenames for node in findall(doctree)( lambda n: "source" in n and not isinstance(n, str) ): 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(): text = text.replace(find, rep) if rstrip_lines: text = "\n".join([li.rstrip() for li in text.splitlines()]) > file_regression.check(text, extension=extension) E AssertionError: FILES DIFFER: E /tmp/pytest-of-mgorny/pytest-10/test_references_singlehtml0/test_sphinx_builds/test_references_singlehtml.resolved.xml E /tmp/pytest-of-mgorny/pytest-10/test_references_singlehtml0/test_sphinx_builds/test_references_singlehtml.resolved.obtained.resolved.xml E HTML DIFF: /tmp/pytest-of-mgorny/pytest-10/test_references_singlehtml0/test_sphinx_builds/test_references_singlehtml.resolved.obtained.resolved.diff.html E --- E +++ E @@ -3,18 +3,18 @@ E E Other Title E <paragraph> E - <reference internal="True" refuri="index.html#document-other/other2"> E + <reference internal="True" refuri="#document-other/other2"> E <inline classes="doc"> E Other 2 Title E <paragraph> E - <reference internal="True" refuri="index.html#document-other/other2"> E + <reference internal="True" refuri="#document-other/other2"> E <inline classes="doc doc doc"> E Other 2 Title E <paragraph> E - <reference internal="True" refuri="index.html#document-other/other2"> E + <reference internal="True" refuri="#document-other/other2"> E <inline classes="std std-doc"> E Other 2 Title E <paragraph> E - <reference internal="True" refuri="index.html#document-index#title"> E + <reference internal="True" refuri="#document-index#title"> E <inline classes="std std-ref"> E Title tests/test_sphinx/conftest.py:131: AssertionError ------------------------------------------------------ Captured stdout teardown ------------------------------------------------------- # testroot: root # builder: singlehtml # srcdir: /tmp/MyST-Parser/tests/test_sphinx/sourcedirs/references_singlehtml # outdir: /tmp/MyST-Parser/tests/test_sphinx/sourcedirs/references_singlehtml/_build/singlehtml # status: Running Sphinx v7.3.7 myst v2.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=2, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True) building [mo]: targets for 0 po files that are out of date writing output... building [singlehtml]: all documents updating environment: [new config] 4 added, 0 changed, 0 removed reading sources... [ 25%] index reading sources... [ 50%] other/index reading sources... [ 75%] other/other reading sources... [100%] other/other2 looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done assembling single document... other/index other/other other/other2 done writing... done writing additional files... done copying static files... done copying extra files... done dumping object inventory... done build succeeded. The HTML page is in tests/test_sphinx/sourcedirs/references_singlehtml/_build/singlehtml. # warning: _______________________________________________________ test_heading_slug_func ________________________________________________________ app = <SphinxTestApp buildername='html'>, status = <_io.StringIO object at 0x7f6d4cfb3520> warning = <_io.StringIO object at 0x7f6d4cfb3250> get_sphinx_app_doctree = <function get_sphinx_app_doctree.<locals>.read at 0x7f6d4c5fc940> get_sphinx_app_output = <function get_sphinx_app_output.<locals>.read at 0x7f6d4c5fca60> @pytest.mark.sphinx( buildername="html", srcdir=os.path.join(SOURCE_DIR, "heading_slug_func"), freshenv=True, ) def test_heading_slug_func( app, status, warning, get_sphinx_app_doctree, get_sphinx_app_output, ): """Test heading_slug_func configuration.""" app.build() assert "build succeeded" in status.getvalue() # Build succeeded warnings = warning.getvalue().strip() > assert warnings == "" E AssertionError: assert '\x1b[91mWARN...x1b[39;49;00m' == '' E E + WARNING: cannot cache unpickable configuration value: 'myst_heading_slug_func' (because it contains a function, class, or module object) tests/test_sphinx/test_sphinx_builds.py:194: AssertionError ------------------------------------------------------ Captured stdout teardown ------------------------------------------------------- # testroot: root # builder: html # srcdir: /tmp/MyST-Parser/tests/test_sphinx/sourcedirs/heading_slug_func # outdir: /tmp/MyST-Parser/tests/test_sphinx/sourcedirs/heading_slug_func/_build/html # status: Running Sphinx v7.3.7 myst v2.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=2, heading_slug_func=<function make_id at 0x7f6d53419870>, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True) building [mo]: targets for 0 po files that are out of date writing output... building [html]: targets for 1 source files that are out of date updating environment: [new config] 1 added, 0 changed, 0 removed reading sources... [100%] index looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done copying assets... copying static files... done copying extra files... done done writing output... [100%] index generating indices... genindex done writing additional pages... search done dumping search index in English (code: en)... done dumping object inventory... done build succeeded, 1 warning. The HTML pages are in tests/test_sphinx/sourcedirs/heading_slug_func/_build/html. # warning: WARNING: cannot cache unpickable configuration value: 'myst_heading_slug_func' (because it contains a function, class, or module object) __________________________________________________________ test_gettext_html __________________________________________________________ app = <SphinxTestApp buildername='html'>, status = <_io.StringIO object at 0x7f6d4c4977f0> warning = <_io.StringIO object at 0x7f6d4c494700> get_sphinx_app_doctree = <function get_sphinx_app_doctree.<locals>.read at 0x7f6d4c31da20> get_sphinx_app_output = <function get_sphinx_app_output.<locals>.read at 0x7f6d4c31db40> @pytest.mark.sphinx( buildername="html", srcdir=os.path.join(SOURCE_DIR, "gettext"), freshenv=True, confoverrides={"language": "fr", "gettext_compact": False, "locale_dirs": ["."]}, ) def test_gettext_html( app, status, warning, get_sphinx_app_doctree, get_sphinx_app_output, ): """Test gettext message extraction.""" app.build() assert "build succeeded" in status.getvalue() # Build succeeded warnings = warning.getvalue().strip() assert warnings == "" try: get_sphinx_app_doctree( app, docname="index", regress=True, ) finally: get_sphinx_app_doctree( app, docname="index", resolve=True, regress=True, ) > get_sphinx_app_output( app, 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"' }, ) tests/test_sphinx/test_sphinx_builds.py:465: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ app = <SphinxTestApp buildername='html'>, buildername = 'html', filename = 'index.html', encoding = 'utf-8', regress_html = True regress_ext = '.html', replace = {'"Permalink to this heading"': '"Lien permanent vers cette rubrique"'} def read( app, buildername="html", filename="index.html", encoding="utf-8", regress_html=False, regress_ext=".html", replace=None, ): outpath = pathlib.Path(str(app.srcdir), "_build", buildername, filename) if not outpath.exists(): raise OSError(f"no output file exists: {outpath}") content = outpath.read_text(encoding=encoding) if regress_html: # only regress the inner body, since other sections are non-deterministic soup = BeautifulSoup(content, "html.parser") doc_div = soup.findAll("div", {"class": "documentwrapper"})[0] # pygments 2.11.0 introduces a whitespace tag 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") E AssertionError: FILES DIFFER: E /tmp/pytest-of-mgorny/pytest-10/test_gettext_html0/test_sphinx_builds/test_gettext_html.html E /tmp/pytest-of-mgorny/pytest-10/test_gettext_html0/test_sphinx_builds/test_gettext_html.obtained.html E HTML DIFF: /tmp/pytest-of-mgorny/pytest-10/test_gettext_html0/test_sphinx_builds/test_gettext_html.obtained.diff.html E --- E +++ E @@ -7,7 +7,7 @@ E <strong> E gras E </strong> E - <a class="headerlink" href="#bold-text-1" title="Lien permanent vers cette rubrique"> E + <a class="headerlink" href="#bold-text-1" title="Lien vers cette rubrique"> E ¶ E </a> E </h1> tests/test_sphinx/conftest.py:87: AssertionError ------------------------------------------------------ Captured stdout teardown ------------------------------------------------------- # testroot: root # builder: html # srcdir: /tmp/MyST-Parser/tests/test_sphinx/sourcedirs/gettext # outdir: /tmp/MyST-Parser/tests/test_sphinx/sourcedirs/gettext/_build/html # status: Running Sphinx v7.3.7 loading translations [fr]... done myst v2.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'deflist'}, disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True) building [mo]: targets for 0 po files that are out of date writing output... building [html]: targets for 1 source files that are out of date updating environment: [new config] 1 added, 0 changed, 0 removed reading sources... [100%] index looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done copying assets... copying static files... done copying extra files... done done writing output... [100%] index generating indices... genindex done writing additional pages... search done copying images... [ 50%] poisson-amusant.png copying images... [100%] fun-fish.png dumping search index in French (code: fr)... done dumping object inventory... done build succeeded. The HTML pages are in tests/test_sphinx/sourcedirs/gettext/_build/html. # warning: ``` </details> <h3>Expected Behavior</h3> <p><em>No response</em></p> <h3>To Reproduce</h3> <p><em>No response</em></p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/chrisjsewell"><img src="https://avatars.githubusercontent.com/u/2997570?v=4" />chrisjsewell</a> commented <strong> 2 months ago</strong> </div> <div class="markdown-body"> <p>fixed</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/mgorny"><img src="https://avatars.githubusercontent.com/u/110765?v=4" />mgorny</a> commented <strong> 2 months ago</strong> </div> <div class="markdown-body"> <p>Thanks a lot!</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>