From a31453064c1cf8a12df76439ec0a7634ff9b9e29 Mon Sep 17 00:00:00 2001 From: Karolina Surma Date: Tue, 31 Jan 2023 16:26:54 +0100 Subject: [PATCH] Fix tests failures with Pygments 2.14 --- fix-tests-with-pygments-2.14.patch | 114 +++++++++++++++++++++++++++++ python-sphinx.spec | 10 ++- 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 fix-tests-with-pygments-2.14.patch diff --git a/fix-tests-with-pygments-2.14.patch b/fix-tests-with-pygments-2.14.patch new file mode 100644 index 0000000..986e7d5 --- /dev/null +++ b/fix-tests-with-pygments-2.14.patch @@ -0,0 +1,114 @@ +From c3bf917fcf18c5211b220a7b294b7e6012c2d510 Mon Sep 17 00:00:00 2001 +From: Adam Turner <9087854+aa-turner@users.noreply.github.com> +Date: Sun, 1 Jan 2023 19:17:03 +0000 +Subject: [PATCH] Fix tests for Pygments 2.14 + +Pygments 2.14 was released on 01/01/2023 [0] + +[0]: https://pygments.org/docs/changelog/#version-2-14-0 + +--- + pyproject.toml | 2 +- + tests/test_ext_viewcode.py | 27 +++++++++++++++++++-------- + tests/test_intl.py | 11 +++++++++-- + 3 files changed, 29 insertions(+), 11 deletions(-) + +diff --git a/pyproject.toml b/pyproject.toml +index 0e059b5..c02ce20 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -64,7 +64,7 @@ dependencies = [ + "sphinxcontrib-serializinghtml>=1.1.5", + "sphinxcontrib-qthelp", + "Jinja2>=3.0", +- "Pygments>=2.12", ++ "Pygments>=2.13", + "docutils>=0.14,<0.20", + "snowballstemmer>=2.0", + "babel>=2.9", +diff --git a/tests/test_ext_viewcode.py b/tests/test_ext_viewcode.py +index 7750b8d..6d443d1 100644 +--- a/tests/test_ext_viewcode.py ++++ b/tests/test_ext_viewcode.py +@@ -2,6 +2,7 @@ + + import re + ++import pygments + import pytest + + +@@ -31,14 +32,24 @@ def test_viewcode(app, status, warning): + + result = (app.outdir / '_modules/spam/mod1.html').read_text(encoding='utf8') + result = re.sub('', '', result) # filter pygments classes +- assert ('
[docs]' +- '@decorator\n' +- 'class Class1' +- '(object):\n' +- ' """\n' +- ' this is Class1\n' +- ' """
\n') in result ++ if pygments.__version__ >= '2.14.0': ++ assert ('
[docs]' ++ '@decorator\n' ++ 'class Class1' ++ '(object):\n' ++ ' """\n' ++ ' this is Class1\n' ++ ' """
\n') in result ++ else: ++ assert ('
[docs]' ++ '@decorator\n' ++ 'class Class1' ++ '(object):\n' ++ ' """\n' ++ ' this is Class1\n' ++ ' """
\n') in result + + + @pytest.mark.sphinx('epub', testroot='ext-viewcode') +diff --git a/tests/test_intl.py b/tests/test_intl.py +index 796d95b..0c4b838 100644 +--- a/tests/test_intl.py ++++ b/tests/test_intl.py +@@ -6,6 +6,7 @@ Runs the text builder in the test root. + import os + import re + ++import pygments + import docutils + import pytest + from babel.messages import mofile, pofile +@@ -1105,8 +1106,11 @@ def test_additional_targets_should_not_be_translated(app): + expected_expr = ("""literal""" + """-""" + """block\n""" +- """in """ ++ """in""" ++ """ """ + """list""") ++ if pygments.__version__ < '2.14.0': ++ expected_expr = expected_expr.replace(""" """, ' ') + assert_count(expected_expr, result, 1) + + # doctest block should not be translated but be highlighted +@@ -1184,8 +1188,11 @@ def test_additional_targets_should_be_translated(app): + expected_expr = ("""LITERAL""" + """-""" + """BLOCK\n""" +- """IN """ ++ """IN""" ++ """ """ + """LIST""") ++ if pygments.__version__ < '2.14.0': ++ expected_expr = expected_expr.replace(""" """, ' ') + assert_count(expected_expr, result, 1) + + # doctest block should not be translated but be highlighted +-- +2.39.1 + diff --git a/python-sphinx.spec b/python-sphinx.spec index 3207bbf..5455f7d 100644 --- a/python-sphinx.spec +++ b/python-sphinx.spec @@ -28,7 +28,7 @@ Name: python-sphinx #global prerel ... %global upstream_version %{general_version}%{?prerel} Version: %{general_version}%{?prerel:~%{prerel}} -Release: 2%{?dist} +Release: 3%{?dist} Epoch: 1 Summary: Python documentation generator @@ -45,6 +45,11 @@ Source0: %{pypi_source %{upstream_name} %{upstream_version}} # which causes that test to fail. Patch1: sphinx-test_theming.diff +# Backported upstream commit included in Sphinx 6+ ensures compatibility +# with python-pygments 2.14+ +# https://github.com/sphinx-doc/sphinx/commit/965768bfda2a00ba6 +Patch2: fix-tests-with-pygments-2.14.patch + BuildArch: noarch BuildRequires: make @@ -359,6 +364,9 @@ mkdir %{buildroot}%{python3_sitelib}/sphinxcontrib %changelog +* Tue Jan 31 2023 Karolina Surma - 1:5.3.0-3 +- Fix tests with python-pygments 2.14+ + * Fri Jan 20 2023 Fedora Release Engineering - 1:5.3.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild