diff --git a/_multibuild b/_multibuild
index fcc7b97..68c43ce 100644
--- a/_multibuild
+++ b/_multibuild
@@ -1,3 +1,3 @@
- test
+ test+doc
diff --git a/autodoc.patch b/autodoc.patch
new file mode 100644
index 0000000..ccf4b15
--- /dev/null
+++ b/autodoc.patch
@@ -0,0 +1,33 @@
+From 0227606e71dc765ed60cd0ad2c580a43b5ffca4f Mon Sep 17 00:00:00 2001
+From: James Addison <55152140+jayaddison@users.noreply.github.com>
+Date: Mon, 12 May 2025 16:52:52 +0000
+Subject: [PATCH] Fix tests for Python 3.14.0a7 (#13527)
+
+Authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
+Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
+Co-authored-by: James Addison <55152140+jayaddison@users.noreply.github.com>
+---
+ tests/test_extensions/test_ext_autodoc.py | 6 +++++-
+ tests/test_extensions/test_ext_autodoc_configs.py | 12 ++++++++++--
+ 2 files changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/tests/test_extensions/test_ext_autodoc.py b/tests/test_extensions/test_ext_autodoc.py
+index a06c1bbe30d..7aa12db3c32 100644
+--- a/tests/test_extensions/test_ext_autodoc.py
++++ b/tests/test_extensions/test_ext_autodoc.py
+@@ -938,10 +938,14 @@ def test_autodoc_special_members(app):
+ }
+ if sys.version_info >= (3, 13, 0, 'alpha', 5):
+ options['exclude-members'] = '__static_attributes__,__firstlineno__'
++ if sys.version_info >= (3, 14, 0, 'alpha', 7):
++ ann_attr_name = '__annotations_cache__'
++ else:
++ ann_attr_name = '__annotations__'
+ actual = do_autodoc(app, 'class', 'target.Class', options)
+ assert list(filter(lambda l: '::' in l, actual)) == [
+ '.. py:class:: Class(arg)',
+- ' .. py:attribute:: Class.__annotations__',
++ f' .. py:attribute:: Class.{ann_attr_name}',
+ ' .. py:attribute:: Class.__dict__',
+ ' .. py:method:: Class.__init__(arg)',
+ ' .. py:attribute:: Class.__module__',
diff --git a/autosummary.patch b/autosummary.patch
new file mode 100644
index 0000000..269324f
--- /dev/null
+++ b/autosummary.patch
@@ -0,0 +1,29 @@
+From 8962398b761c3d85a7c74b6f789b3ffb127bde0c Mon Sep 17 00:00:00 2001
+From: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
+Date: Thu, 6 Mar 2025 16:03:44 +0000
+Subject: [PATCH] autosummary: Update test for Python 3.14.0a5+ (#13418)
+
+`types.UnionType` and `typing.Union` have been merged.
+---
+ tests/test_extensions/test_ext_autosummary.py | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/tests/test_extensions/test_ext_autosummary.py b/tests/test_extensions/test_ext_autosummary.py
+index 35dc7d180ef..c807ddba3d1 100644
+--- a/tests/test_extensions/test_ext_autosummary.py
++++ b/tests/test_extensions/test_ext_autosummary.py
+@@ -447,8 +447,12 @@ def test_autosummary_generate_content_for_module_imported_members(app):
+ ]
+ assert context['functions'] == ['bar']
+ assert context['all_functions'] == ['_quux', 'bar']
+- assert context['classes'] == ['Class', 'Foo']
+- assert context['all_classes'] == ['Class', 'Foo', '_Baz']
++ if sys.version_info >= (3, 14, 0, 'alpha', 5):
++ assert context['classes'] == ['Class', 'Foo', 'Union']
++ assert context['all_classes'] == ['Class', 'Foo', 'Union', '_Baz']
++ else:
++ assert context['classes'] == ['Class', 'Foo']
++ assert context['all_classes'] == ['Class', 'Foo', '_Baz']
+ assert context['exceptions'] == ['Exc']
+ assert context['all_exceptions'] == ['Exc', '_Exc']
+ assert context['attributes'] == ['CONSTANT1', 'qux', 'quuz', 'non_imported_member']
diff --git a/docutils022.patch b/docutils022.patch
new file mode 100644
index 0000000..4d12ccf
--- /dev/null
+++ b/docutils022.patch
@@ -0,0 +1,50 @@
+From 68d56109ff50dd81dd31d4a01e3dccbd006c50ee Mon Sep 17 00:00:00 2001
+From: James Addison <55152140+jayaddison@users.noreply.github.com>
+Date: Mon, 2 Jun 2025 22:02:48 +0000
+Subject: [PATCH] Tests: update LaTeX label test expectations from Docutils
+ r10151 (#13610)
+
+Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
+---
+ tests/test_builders/test_build_latex.py | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/tests/test_builders/test_build_latex.py b/tests/test_builders/test_build_latex.py
+index 0d1c607462d..37e708a021e 100644
+--- a/tests/test_builders/test_build_latex.py
++++ b/tests/test_builders/test_build_latex.py
+@@ -12,6 +12,7 @@
+ from subprocess import CalledProcessError
+ from typing import TYPE_CHECKING
+
++import docutils
+ import pygments
+ import pytest
+
+@@ -1959,10 +1960,16 @@ def test_latex_labels(app: SphinxTestApp) -> None:
+
+ result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
+
++ # ref: docutils r10151
++ if docutils.__version_info__[:2] < (0, 22):
++ figure_id, table_id = 'id1', 'id2'
++ else:
++ figure_id, table_id = 'id2', 'id3'
++
+ # figures
+ assert (
+ r'\caption{labeled figure}'
+- r'\label{\detokenize{index:id1}}'
++ r'\label{\detokenize{index:' + figure_id + '}}'
+ r'\label{\detokenize{index:figure2}}'
+ r'\label{\detokenize{index:figure1}}'
+ r'\end{figure}'
+@@ -1988,7 +1995,7 @@ def test_latex_labels(app: SphinxTestApp) -> None:
+ # tables
+ assert (
+ r'\sphinxcaption{table caption}'
+- r'\label{\detokenize{index:id2}}'
++ r'\label{\detokenize{index:' + table_id + '}}'
+ r'\label{\detokenize{index:table2}}'
+ r'\label{\detokenize{index:table1}}'
+ ) in result
diff --git a/python-Sphinx.changes b/python-Sphinx.changes
index ae9c898..4f9fc4f 100644
--- a/python-Sphinx.changes
+++ b/python-Sphinx.changes
@@ -1,3 +1,15 @@
+-------------------------------------------------------------------
+Thu Sep 11 08:42:26 UTC 2025 - Markéta Machová
+
+- Add upstream patches to fix tests with Python 3.14:
+ * autodoc.patch
+ * autosummary.patch
+ * typing.patch
+- Proactively add upstream patch to fix tests with docutils 0.22:
+ * docutils022.patch
+- Rename multibuild flavor 'test' to 'test+doc' to better reflect
+ the current behaviour
+
-------------------------------------------------------------------
Mon Aug 25 12:56:50 UTC 2025 - Markéta Machová
diff --git a/python-Sphinx.spec b/python-Sphinx.spec
index 8117d04..bdaa9ba 100644
--- a/python-Sphinx.spec
+++ b/python-Sphinx.spec
@@ -17,7 +17,7 @@
%global flavor @BUILD_FLAVOR@%{nil}
-%if "%{flavor}" == "test"
+%if "%{flavor}" == "test+doc"
%define psuffix -test
%bcond_without test
%else
@@ -47,6 +47,14 @@ Source3: requests.inv
Source4: readthedocs.inv
Source5: update-intersphinx.sh
Source99: python-Sphinx.keyring
+# PATCH-FIX-UPSTREAM https://github.com/sphinx-doc/sphinx/pull/13527 Followup-to: Fix tests for Python 3.14a7+
+Patch0: autodoc.patch
+# PATCH-FIX-UPSTREAM https://github.com/sphinx-doc/sphinx/commit/8962398b761c3d85a7c74b6f789b3ffb127bde0c autosummary: Update test for Python 3.14.0a5+
+Patch1: autosummary.patch
+# PATCH-FIX-UPSTREAM https://github.com/sphinx-doc/sphinx/commit/e01e42f5fc738815b8499c4ede30c6caf130f0a4 Fix INVALID_BUILTIN_CLASSES test for Python 3.14.0a6+
+Patch2: typing.patch
+# PATCH-FIX-UPSTREAM https://github.com/sphinx-doc/sphinx/commit/68d56109ff50dd81dd31d4a01e3dccbd006c50ee Tests: update LaTeX label test expectations from Docutils r10151
+Patch3: docutils022.patch
BuildRequires: %{python_module base}
BuildRequires: %{python_module flit-core >= 3.11}
BuildRequires: %{python_module pip}
diff --git a/typing.patch b/typing.patch
new file mode 100644
index 0000000..bfc96d7
--- /dev/null
+++ b/typing.patch
@@ -0,0 +1,40 @@
+From e01e42f5fc738815b8499c4ede30c6caf130f0a4 Mon Sep 17 00:00:00 2001
+From: Adam Turner <9087854+aa-turner@users.noreply.github.com>
+Date: Wed, 19 Mar 2025 20:11:35 +0000
+Subject: [PATCH] Fix ``INVALID_BUILTIN_CLASSES`` test for Python 3.14.0a6+
+
+---
+ tests/test_util/test_util_typing.py | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/tests/test_util/test_util_typing.py b/tests/test_util/test_util_typing.py
+index 35ee240f7b8..8a561c378ed 100644
+--- a/tests/test_util/test_util_typing.py
++++ b/tests/test_util/test_util_typing.py
+@@ -205,7 +205,7 @@ def test_is_invalid_builtin_class() -> None:
+ zipfile.Path,
+ zipfile.CompleteDirs,
+ )
+- if sys.version_info[:2] >= (3, 13):
++ if sys.version_info[:2] == (3, 13):
+ invalid_types += (
+ # pathlib
+ Path,
+@@ -217,7 +217,7 @@ def test_is_invalid_builtin_class() -> None:
+ )
+
+ invalid_names = {(cls.__module__, cls.__qualname__) for cls in invalid_types}
+- if sys.version_info[:2] < (3, 13):
++ if sys.version_info[:2] != (3, 13):
+ invalid_names |= {
+ ('pathlib._local', 'Path'),
+ ('pathlib._local', 'PosixPath'),
+@@ -231,7 +231,7 @@ def test_is_invalid_builtin_class() -> None:
+ ('zipfile._path', 'Path'),
+ ('zipfile._path', 'CompleteDirs'),
+ }
+- assert _INVALID_BUILTIN_CLASSES.keys() == invalid_names
++ assert set(_INVALID_BUILTIN_CLASSES) == invalid_names
+
+
+ def test_restify_type_hints_containers():