18
18
from pathlib import Path
19
19
from collections .abc import Mapping , Callable
20
20
21
- from pytest_mock import MockerFixture
22
21
from sphinx .application import Sphinx
23
22
24
23
Tree : TypeAlias = Mapping [str | Path , "Tree | str" ]
@@ -67,18 +66,16 @@ def files(app: Sphinx, index_filename: str, index_template: str) -> Tree:
67
66
if "myst_parser" in app .extensions :
68
67
files = {
69
68
index_filename : index_template .format ("." ),
70
- "1.2.0.md" : "### 1.2.0" ,
71
- "1.2.1.md" : "### 1.2.1" ,
72
- "1.3.0.md" : "### 1.3.0" ,
73
- "1.3.2.md" : "### 1.3.2" ,
69
+ "1.2.0.md" : "(v1.2.0)=\n ### 1.2.0" ,
70
+ "1.2.1.md" : "(v1.2.1)=\n ### 1.2.1" ,
71
+ "1.3.0rc1.md" : "(v1.3.0rc1)=\n ### 1.3.0rc1" ,
74
72
}
75
73
else :
76
74
files = {
77
75
index_filename : index_template .format ("." ),
78
- "1.2.0.rst" : "1.2.0\n =====" ,
79
- "1.2.1.rst" : "1.2.1\n =====" ,
80
- "1.3.0.rst" : "1.3.0\n =====" ,
81
- "1.3.2.rst" : "1.3.2\n =====" ,
76
+ "1.2.0.rst" : ".. _v1.2.0:\n 1.2.0\n =====" ,
77
+ "1.2.1.rst" : ".. _v1.2.1:\n 1.2.1\n =====" ,
78
+ "1.3.0rc1.rst" : ".. _v1.3.0rc1:\n 1.3.0rc1\n ========" ,
82
79
}
83
80
return files
84
81
@@ -88,20 +85,20 @@ def files(app: Sphinx, index_filename: str, index_template: str) -> Tree:
88
85
<section ids="version-1-3 v1-3" names="version\\ 1.3 v1.3">
89
86
<title>
90
87
Version 1.3
91
- <section ids="id1" names="1.3.2">
88
+ <target refid="v1-3-0rc1">
89
+ <section ids="rc1 v1-3-0rc1" names="1.3.0rc1 v1.3.0rc1">
92
90
<title>
93
- 1.3.2
94
- <section ids="id2" names="1.3.0">
95
- <title>
96
- 1.3.0
91
+ 1.3.0rc1
97
92
<target refid="v1-2">
98
93
<section ids="version-1-2 v1-2" names="version\\ 1.2 v1.2">
99
94
<title>
100
95
Version 1.2
101
- <section ids="id3" names="1.2.1">
96
+ <target refid="v1-2-1">
97
+ <section ids="v1-2-1 id1" names="1.2.1 v1.2.1">
102
98
<title>
103
99
1.2.1
104
- <section ids="id4" names="1.2.0">
100
+ <target refid="v1-2-0">
101
+ <section ids="v1-2-0 id2" names="1.2.0 v1.2.0">
105
102
<title>
106
103
1.2.0
107
104
"""
@@ -143,7 +140,7 @@ def test_error_wrong_file(
143
140
144
141
145
142
def test_error_no_src (
146
- mocker : MockerFixture ,
143
+ monkeypatch : pytest . MonkeyPatch ,
147
144
tmp_path : Path ,
148
145
app : Sphinx ,
149
146
files : Tree ,
@@ -152,7 +149,7 @@ def test_error_no_src(
152
149
pytest .skip ("rst parser doesn’t need this" )
153
150
app .warningiserror = True
154
151
rn , _ = directives .directive ("release-notes" , get_language ("en" ), new_document ("" ))
155
- mocker . patch . object (rn , "get_source_info" , return_value = ("<string>" , 0 ))
152
+ monkeypatch . setattr (rn , "get_source_info" , lambda * _ , ** __ : ("<string>" , 0 ))
156
153
157
154
mkfiles (tmp_path , files )
158
155
with pytest .raises (SphinxWarning , match = r"Cannot find relative path to: <string>" ):
0 commit comments